# -*- coding: utf-8 -*- # 6to4 Configuration Script # Author: github.com/Azumi67 # This is for educational use and my own learning, please provide me with feedback if possible # This script is designed to simplify the configuration of 6to4 tunnels. # # Supported operating systems: Ubuntu 20, Debian 12, Ubuntu 22, Ubuntu 22 # # Usage: # - Run the script with root privileges. # - Follow the on-screen prompts to install, configure, or uninstall the tunnel. # # # Disclaimer: # This script comes with no warranties or guarantees. Use it at your own risk. import sys import re import os import shutil import time import colorama from colorama import Fore, Style import subprocess from time import sleep import readline import netifaces import netifaces as ni import io import ipaddress sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding="utf-8", errors="replace") if os.geteuid() != 0: print("\033[91mThis script must be run as root. Please use sudo -i.\033[0m") sys.exit(1) def logo(): logo_path = "/etc/logo2.sh" try: subprocess.run(["bash", "-c", logo_path], check=True) except subprocess.CalledProcessError as e: return e return None SYSCTL_CONF = "/etc/sysctl.conf" BACKUP_CONF = "/etc/sysctl.conf.backup" SETTINGS = { "net.ipv4.ip_forward": "1", "net.ipv6.conf.all.disable_ipv6": "0", "net.ipv6.conf.default.disable_ipv6": "0", "net.ipv6.conf.all.forwarding": "1", } def backup_sysctl(): if not os.path.exists(BACKUP_CONF): shutil.copy(SYSCTL_CONF, BACKUP_CONF) print(f"\033[93mBackup created at {BACKUP_CONF}\033[0m") else: print(f"\033[92mBackup already exists at {BACKUP_CONF}\033[0m") def apply(): with open(SYSCTL_CONF, "r") as file: lines = file.readlines() current_settings = {} for line in lines: if "=" in line: key, value = line.strip().split("=", 1) current_settings[key.strip()] = value.strip() with open(SYSCTL_CONF, "a") as file: for key, value in SETTINGS.items(): if current_settings.get(key) != value: file.write(f"{key} = {value}\n") subprocess.run(["sysctl", "-w", f"{key}={value}"]) print(f"\033[92mApplied \033[94m{key} \033[93m= \033[94m{value}\033[0m") else: print(f"\033[94m{key}\033[93m is already set to {value}\033[0m") def restore_backup(): if os.path.exists(BACKUP_CONF): shutil.copy(BACKUP_CONF, SYSCTL_CONF) subprocess.run(["sysctl", "-p"]) print(f"\033[93mRestored configuration from {BACKUP_CONF}\033[0m") else: print(f"\033[91mNo backup found at {BACKUP_CONF}\033[0m") def display_progress(total, current): width = 40 percentage = current * 100 // total completed = width * current // total remaining = width - completed print( "\r[" + "=" * completed + ">" + " " * remaining + "] %d%%" % percentage, end="" ) def display_checkmark(message): print("\u2714 " + message) def display_error(message): print("\u2718 Error: " + message) def display_notification(message): print("\u2728 " + message) def display_loading(): frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 5 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[" + frame + "] Loading... ", end="") time.sleep(delay) print("\r[" + frame + "] ", end="") time.sleep(delay) def display_logo(): colorama.init() logo = """ \033[1;96m ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠀⢀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠀⡀⠤⠒⠊⠉⠀⠀⠀⠀⠈⠁⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀\033[1;93m⠀⢀⠔⠉⠀⠀⠀⠀⢀⡠⠤⠐⠒⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠀⣀⡠⠤⠤⠀⠀⠂⠐\033[1;96m⠀⠠⢤⠎⢑⡭⣽⣳⠶⣖⡶⣤⣖⣬⡽⡭⣥⣄\033[1;93m⠒⠒⠀⠐⠁⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⢀⠴⠊⠁⠀⠀⠀⠀⡀⠀\033[1;96m⣠⣴⡶⣿⢏⡿⣝⡳⢧⡻⣟⡻⣞⠿⣾⡽⣳⣯⣳⣞⡻⣦⡀⠀⠀\033[1;93m⠀⠈⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⢨⠀⠀⠀⢀⠤⠂⠁\033[1;96m⢠⣾⡟⣧⠿⣝⣮⣽⢺⣝⣳⡽⣎⢷⣫⡟⡵⡿⣵⢫⡷⣾⢷⣭⢻⣦⡄\033[1;93m⠤⡸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠘⡄⠀⠀⠓⠂⠀\033[1;96m⣴⣿⢷⡿⣝⣻⣏⡷⣾⣟⡼⣣⢟⣼⣣⢟⣯⢗⣻⣽⣏⡾⡽⣟⣧⠿⡼⣿⣦\033[1;93m⣃⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⢀⠇⠀⠀⠀⠀\033[1;96m⣼⣿⢿⣼⡻⣼⡟⣼⣧⢿⣿⣸⡧⠿⠃⢿⣜⣻⢿⣤⣛⣿⢧⣻⢻⢿⡿⢧⣛⣿⣧⠀\033[1;93m⠛⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⢸⠁⠀⠀⠀⠀\033[1;96m⣼⣻⡿⣾⣳⡽⣾⣽⡷⣻⣞⢿⣫⠕⣫⣫⣸⢮⣝⡇⠱⣏⣾⣻⡽⣻⣮⣿⣻⡜⣞⡿⣷\033[1;93m⢀⠀⠀⠑⠢⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠘⣧⠀⠀⠀\033[1;96m⣼⣳⢯⣿⣗⣿⣏⣿⠆⣟⣿⣵⢛⣵⡿⣿⣏⣟⡾⣜⣻⠀⢻⡖⣷⢳⣏⡶⣻⡧⣟⡼⣻⡽⣇\033[1;93m⠁⠢⡀⠠⡀⠑⡄⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠈⢦⠀\033[1;96m⣰⣯⣟⢯⣿⢾⣹⢾⡟⠰⣏⡾⣾⣟⡷⣿⣻⣽⣷⡶⣟⠿⡆⠀⢻⣝⣯⢷⣹⢧⣿⢧⡻⣽⣳⢽⡀\033[1;93m⠀⠈⠀⠈⠂⡼⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠀⡀⢵\033[1;96m⣟⣾⡟⣾⣿⣻⢽⣺⠇⠀⣿⡱⢿⡞⣵⡳⣭⣿⡜⣿⣭⣻⣷⠲⠤⢿⣾⢯⢯⣛⢿⣳⡝⣾⣿⢭⡇⠀\033[1;93m⠀⠀⠀⡰⠁⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⢀⠤⠊⠀\033[1;96m⣼⢻⣿⢞⣯⢿⡽⣸⣹⡆⠀⢷⣏⢯⣿⣧⣛⠶⣯⢿⣽⣷⣧⣛⣦⠀⠀⠙⢿⣳⣽⣿⣣⢟⡶⣿⣫⡇⠀⠀\033[1;93m⠀⠰⠁⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⣠⠖⠁⠀⠀⡄\033[1;96m⡿⣯⣷⣻⡽⣞⡟⣿⣿⣟⠉⠈⢯⣗⣻⣕⢯⣛⡞⣯⢮⣷⣭⡚⠓⠋⠀⠀⠀⠈⠉⣿⡽⣎⠷⡏⡷⣷⠀⠀⠀\033[1;93m⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠐⣇⠀⠀⢀⠊\033[1;96m⣼⣇⣿⡗⣿⣽⣷⡿⣿⣱⡿⣆⠀⠀⠙⠒⠛⠓⠋⠉⠉⠀⠀⠀\033[1;91m⢠⣴⣯⣶⣶⣤⡀\033[1;96m ⠀⣿⣟⡼⣛⡇⣟⣿⡆\033[1;93m⡀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠘⢤⠀⠃⠌\033[1;96m⣸⣿⢾⡽⣹⣾⠹⣞⡵⣳⣽⡽⣖⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\033[1;91m⣤⣖⣻⣾⣝⢿⡄\033[1;96m ⢸⣯⢳⣏⡿⣏⣾⢧\033[1;93m⠈⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠘⠀⠈⠀\033[1;96m⡿⣿⣻⡽⣽⣿⢧⠌⠉\033[1;91m⠉⣴⣿⣿⣫⣅⡀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣛⠿⠿⢟⢙⡄⠙\033[1;96m ⠘⣯⢳⣞⡟⣯⢾⣻⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⡇⠀⠀⠀\033[1;96m⡿⣿⣿⢵⣫⣿⣆⠁⠂\033[1;91m⣼⡿⢹⣿⡿⠽⠟⢢⠀⠀⠀⠀⠀⠀⠀⢹⠀⢄⢀⠀⡿⠀⠀\033[1;96m ⢰⣯⢷⣺⣏⣯⢻⡽⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⡇⠀⢀⠠\033[1;96m⣿⣿⢾⣛⡶⣽⠈⢓⠀\033[1;91m⢻⠁⢸⠇⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠑⠠⠤⠔⠂⠀⠀\033[1;96m ⢸⣿⢮⣽⠿⣜⣻⡝⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀\033[1;93m⠀⠑⠊⠁\033[1;96m⢠⡷⡇⣿⣿⢼⣹⡀⠀⠑⢄⠀\033[1;91m⠀⠃⠌⣁⠦⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠂⠀⠀\033[1;96m⢀⣿⢾⡝⣾⡽⣺⢽⣹⣽⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣻⢽⣻⡟⣮⣝⡷⢦⣄⣄⣢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣯⢿⡺⣟⢷⡹⢾⣷⡞⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣟⡿⣎⢿⡽⣳⢮⣿⣹⣾⣯⡝⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⣀⣴⡟⣿⢧⣏⢷⡟⣮⠝⢿⣹⣯⡽⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣯⡷⣏⣾⡳⣽⢺⣷⡹⣟⢶⡹⣾⡽⣷⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠔⣾⢯⣷⡇⣿⢳⣎⢿⡞⣽⢦⣼⡽⣧⢻⡽⣆⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣟⢾⡷⣭⣿⢳⣭⢻⣷⡻⣜⣻⡵⣻⡼⣿⠾⠫\033[1;96m⣽⣟⣶⣶⣶⠒⠒⠂⠉⠀\033[1;96m⢸⣽⢺⡷⣷⣯⢗⣮⣟⢾⢧⣻⠼⡿⣿⢣⡟⣼⣆⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡾⣝⣾⢳⢧⣟⡳⣎⣿⣿⣱⢏⣾⣽⣳⠟\033[1;92m⠁⠀⡌⠈\033[1;96m⢹⡯⠟⠛⠀⠀⠀⠀⠀⠈\033[1;96m⣷⢻⣼⣽⣿⡾⣼⣏⣾⣻⡜⣯⣷⢿⣟⣼⡳⣞⣦⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⢿⡸⣎⠿⣾⡏⣷⣉⣷⣿⢹⣎⡿\033[1;92m⠎⡎⠀⠀⠀⡇⠀⣾⠱⡀⠀⠀⠀⠀⠀⠀⠀⠈⣹⠉⡏⠀\033[1;96m⠹⣾⣏⢹⣶⢹⣶⢿⡾⣿⢶⣿⣸⠾⣇⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⣠⣾⢫⣞⡽⣯⢿⣹⡟⣶⣹⢷⣻\033[1;92m⡷⠊⠀⡜⠀⠀⠀⠀⢱⠀⣿⡀⠈⠢⢀⣀⣀⠠⠄⠒⢈⡏⡰⠀⠀⠀\033[1;96m⠀⣿⡜⣮⢟⡼⣻⡵⣻⣗⠾⣟⣯⢻⣆⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⢀⣴⣿⢣⣟⡾⣽⣯⢳⣿⡹⣖⣿⡳\033[1;92m⠋⠀⠀⡸⠀⠀⠀⠀⠀⢸⠀⢺⢂⠀⠀⠀⠀⠀⠀⠀⢠⡺⡱⠁⠀⠀⠀⠀\033[1;96m⢹⣧⣻⢮⡳⣝⡷⢧⣻⢯⢿⣻⣳⢞⡆⠀⠀⠀ ⠀⠀⠀⠀⢀⡾⣽⣣⡿⣼⣏⡿⣼⣳⡯⢷⣹⣯⠇\033[1;92m⠀⠀⢠⠁⠀⠀⠀⠀⠀⠈⡆⠈⢹⡰⠤⡀⠀⠀⠀⢠⡼⢱⠁⠀⠀⠀⠀⠀⠀\033[1;96m⠹⣿⣿⣱⣻⣼⣏⢷⣯⣿⡳⣿⣎⢿⡀⠀⠀ ⠀⠀⠀⠀⣾⣽⠷⣿⣵⡿⣼⡟⣭⣷⡟⣿⢯⡏⠀\033[1;92m⠀⠀⠘⠀⠀⠒⠈⢡⠀⠀⢗⢄⠀⠃⠀⠺⢁⢈⠥⠋⣀⠇⠀⠀⠀⠀⠀⠀⡀⠀\033[1;96m⠈⠙⢿⣳⢞⣽⢯⣞⣾⣯⡝⣿⡾⡇⠀⠀⠀ \033[96m __ \033[1;94m ________ \033[1;92m ____ ____ \033[1;93m ___ ___ \033[1;91m __ \033[96m /""\ \033[1;94m (" "\ \033[1;92m(" _||_ " |\033[1;93m|" \ /" | \033[1;91m|" \ \033[96m / \ \033[1;94m \___/ :)\033[1;92m| ( ) : |\033[1;93m \ \ // | \033[1;91m|| | \033[96m /' /\ \ \033[1;94m / ___/ \033[1;92m(: | | . )\033[1;93m /\ \/. |\033[1;91m |: | \033[96m // __' \ \033[1;94m // \__ \033[1;92m \ \__/ / \033[1;93m|: \. | \033[1;91m|. | \033[96m / / \ \ \033[1;94m(: / "\ \033[1;92m /\ __ /\ \033[1;93m|. \ /: |\033[1;91m /\ |\ \033[96m(___/ \___) \033[1;94m\_______)\033[1;92m(__________)\033[1;93m|___|\__/|___|\033[1;91m(__\_|_) \033[1;92mAuthor: github.com/Azumi67 \033[1;96m """ print(logo) def main_menu(): try: while True: display_logo() border = "\033[93m+" + "=" * 70 + "+\033[0m" content = "\033[93m║ ▌║█║▌│║▌│║▌║▌█║ \033[92mMain Menu\033[93m ▌│║▌║▌│║║▌█║▌ ║" footer = " \033[92m Open issues at \033[34mhttps://github.com/Azumi67/6TO4-GRE-IPIP-SIT\033[0m " border_length = len(border) - 2 centered_content = content.center(border_length) print(border) print(centered_content) print(border) print(border) print(footer) print(border) print( "\033[93m─────────────────────────────────────────────────────────────────────\033[0m" ) display_notification("\033[93mFuture Updates\033[0m") print( "\033[93m─────────────────────────────────────────────────────────────────────\033[0m" ) print(". \033[92mDNS + Other methods\033[93m[Working on it]\033[0m") print( ". \033[93mLocaltun_TCP : https://github.com/Azumi67/LocalTun_TCP\033[0m" ) print(". \033[93mVxlan + Bridge\033[92m[Single Added]\033[0m") print( ". \033[92mStatus Added & Fixed\033[97m[Ping Will be added later]\033[0m" ) print( ". \033[93mEdit Local IP Added[I may add others]\033[97m[NEW]\033[0m" ) print(". \033[96mISATAP Server & Client Added in Multi (4)\033[0m") print( ". \033[97mWireguard local tunnel Added in Multi (4)\033[92m[NEW]\033[0m" ) print( ". \033[93mNext update will be Localtun & wireguard & some other methods and vxlan multi\033[0m" ) print( "\033[93m─────────────────────────────────────────────────────────────────────\033[0m" ) display_notification("\033[93mMethods & Configs\033[0m") print( "\033[93m─────────────────────────────────────────────────────────────────────\033[0m" ) print("0. \033[91mStaus \033[97mMenu\033[0m") print("1. \033[94mEnable IPV4/IPV6 Forwarding \033[0m") print("2. \033[93mSingle Server \033[97mMenu\033[0m") print( "3. \033[92mMultiple Servers \033[97mMenu\033[92m - [10]KHAREJ [1]IRAN \033[93m| [1]KHAREJ [5]IRAN \033[0m" ) print( "4. \033[93mMultiple Servers \033[97mMenu\033[92m - [10]KHAREJ [5]IRAN |\033[96mWireguard Added\033[0m" ) print("5. \033[96mBBR FQ Codel [For IPSEC] BY Kalilovers\033[0m") print("6. \033[93mReset timer for Local Tunnels\033[0m") print("7. \033[92mEdit Local Tunnels\033[0m") print("8. \033[93mLocalTun \033[97m[working on it]\033[0m") print("9. \033[92mReconfig Robot \033[97m[Single Added]\033[0m") print("q. Exit") print( "\033[93m╰─────────────────────────────────────────────────────────────────────╯\033[0m" ) choice = input("\033[5mEnter your choice Please: \033[0m") print("choice:", choice) if choice == "0": status_mnu() elif choice == "1": update_sysctl() elif choice == "2": singleserver_mnu() elif choice == "3": multiserver_mnu() elif choice == "4": multi2server_mnu() elif choice == "5": bibi_codel() elif choice == "6": locals_reset() elif choice == "7": edit_local() elif choice == "8": edit_local() elif choice == "9": robot_menu() elif choice == "q": print("Exiting...") sys.exit() else: print("Invalid choice.") input("Press Enter to continue...") except KeyboardInterrupt: display_error("\033[91m\nProgram interrupted. Exiting...\033[0m") sys.exit() # wireguard def wireguard_allinone_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[93mMenu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("0. \033[91mStatus\033[0m") print("1. \033[92mWireguard \033[0m") print("2. \033[93mWireguard + GRE6tap\033[0m") print("3. \033[94mSit + Wireguard \033[0m") print("4. \033[93mGRE6tap [Native] + Wireguard\033[0m") print("5. \033[92mEdit MTU\033[0m") print("6. \033[93mEdit local\033[0m") print("7. \033[93mEdit IPSEC timer\033[0m") print("8. \033[91mUninstall\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("q.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "0": wireguard_status() break elif server_type == "1": wireguardudp_menu() break elif server_type == "2": wireguardgre6tap_mnu() break elif server_type == "3": wireguardsit_menu() break elif server_type == "4": wireguardgre6tapnative_mnu() break elif server_type == "5": wireguard_mtu() break elif server_type == "6": wireguard_edit_server() break elif server_type == "7": enable_reset_ipsec2() break elif server_type == "8": Wireguard_uninstall() break elif server_type == "q": os.system("clear") multi2server_mnu() break else: print("Invalid choice.") # def enable_reset_ipsec2(): ipsec_service_remove() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input("\033[93mDo you want to edit \033[96mIPSEC \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m").lower() if enable_reset in ['yes', 'y']: print("\033[93m╭───────────────────────────────────────╮\033[0m") print('1. \033[92mHour\033[0m') print('2. \033[93mMinute\033[0m') print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == '1': time_unit = 'hour' elif time_unit_choice == '2': time_unit = 'minute' else: print("\033[91mWrong choice\033[0m") return time_value = input("\033[93mEnter the \033[92mdesired input\033[93m:\033[0m ").strip() interval_seconds = int(time_value) * 3600 if time_unit == 'hour' else int(time_value) * 60 reset_ipsec(interval_seconds) print("\033[93m────────────────────────────────────────\033[0m") def wireguard_mtu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard Edit MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard\033[0m") print("2. \033[93mWireguard & GRE6TAP \033[0m") print("3. \033[92mWireguard & SIT \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardmtu_mnu() break elif server_type == "2": wireguardgre6tapmtu_mnu() break elif server_type == "3": wireguardsitmtu_mnu() break elif server_type == "0": clear() wireguard_allinone_mnu() break else: print("Invalid choice.") def wireguardsitmtu_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard SIT Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer Configs\033[0m") print("2. \033[93mClients \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardsitmtuserver_mnu() break elif server_type == "2": wireguardsitmtuclients_mnu() break elif server_type == "0": clear() wireguardsitmtu_mnu() break else: print("Invalid choice.") def wireguardsitmtuserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard SIT Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_server1() priv_kh1_mtu() break elif server_type == "2": modify_wireguard_mtu_server2() priv_kh2_mtu() break elif server_type == "3": modify_wireguard_mtu_server3() priv_kh3_mtu() break elif server_type == "4": modify_wireguard_mtu_server4() priv_kh4_mtu() break elif server_type == "5": modify_wireguard_mtu_server5() priv_kh5_mtu() break elif server_type == "0": clear() wireguardsitmtu_mnu() break else: print("Invalid choice.") def wireguardsitmtuclients_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard SIT Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_client1() priv_kh1_mtu() break elif server_type == "2": modify_wireguard_mtu_client1() priv_kh2_mtu() break elif server_type == "3": modify_wireguard_mtu_client1() priv_kh3_mtu() break elif server_type == "4": modify_wireguard_mtu_client1() priv_kh4_mtu() break elif server_type == "5": modify_wireguard_mtu_client1() priv_kh5_mtu() break elif server_type == "0": clear() wireguardsitmtu_mnu() break else: print("Invalid choice.") def wireguardgre6tapmtu_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard GRE6TAP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer Configs\033[0m") print("2. \033[93mClients \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardgre6tapmtuserver_mnu() break elif server_type == "2": wireguardgre6tapmtuclients_mnu() break elif server_type == "0": clear() wireguardgre6tapmtu_mnu() break else: print("Invalid choice.") def wireguardgre6tapmtuserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard GRE6TAP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_server1() gre6_kh1tap_mtu() break elif server_type == "2": modify_wireguard_mtu_server2() gre6_kh2tap_mtu() break elif server_type == "3": modify_wireguard_mtu_server3() gre6_kh3tap_mtu() break elif server_type == "4": modify_wireguard_mtu_server4() gre6_kh4tap_mtu() break elif server_type == "5": modify_wireguard_mtu_server5() gre6_kh5tap_mtu() break elif server_type == "0": clear() wireguardgre6tapmtu_mnu() break else: print("Invalid choice.") def wireguardgre6tapmtuclients_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard GRE6TAP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_client1() gre6_kh1tap_mtu() break elif server_type == "2": modify_wireguard_mtu_client1() gre6_kh2tap_mtu() break elif server_type == "3": modify_wireguard_mtu_client1() gre6_kh3tap_mtu() break elif server_type == "4": modify_wireguard_mtu_client1() gre6_kh4tap_mtu() break elif server_type == "5": modify_wireguard_mtu_client1() gre6_kh5tap_mtu() break elif server_type == "0": clear() wireguardgre6tapmtu_mnu() break else: print("Invalid choice.") def wireguardmtu_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer Configs\033[0m") print("2. \033[93mClients \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardmtuserver_mnu() break elif server_type == "2": wireguardmtuclients_mnu() break elif server_type == "0": clear() wireguard_mtu() break else: print("Invalid choice.") def wireguardmtuserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_server1() break elif server_type == "2": modify_wireguard_mtu_server2() break elif server_type == "3": modify_wireguard_mtu_server3() break elif server_type == "4": modify_wireguard_mtu_server4() break elif server_type == "5": modify_wireguard_mtu_server5() break elif server_type == "0": clear() wireguardmtu_mnu() break else: print("Invalid choice.") def wireguardmtuclients_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": modify_wireguard_mtu_client1() break elif server_type == "2": modify_wireguard_mtu_client1() break elif server_type == "3": modify_wireguard_mtu_client1() break elif server_type == "4": modify_wireguard_mtu_client1() break elif server_type == "5": modify_wireguard_mtu_client1() break elif server_type == "0": clear() wireguardmtu_mnu() break else: print("Invalid choice.") def modify_wireguard_mtu_client1(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mCLIENT:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Client] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireclient.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireclient.conf"], check=True ) subprocess.run(["wg-quick", "up", "/etc/wireguard/wireclient.conf"], check=True) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def modify_wireguard_mtu_server1(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mServer Config [1]:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Server Config 1] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireserver1.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver1.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver1.conf"], check=True ) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def modify_wireguard_mtu_server2(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mServer Config [2]:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Server Config 2] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireserver2.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver2.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver2.conf"], check=True ) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def modify_wireguard_mtu_server3(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mServer Config [3]:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Server Config 3] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireserver3.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver3.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver3.conf"], check=True ) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def modify_wireguard_mtu_server4(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mServer Config [4]:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Server Config 4] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireserver4.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver4.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver4.conf"], check=True ) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def modify_wireguard_mtu_server5(): print("\033[93m───────────────────────────────────────\033[0m") print("\033[92mServer Config [5]:\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mWireGuard \033[97m[Server Config 5] \033[93m]:\033[0m " ) config_file = "/etc/wireguard/wireserver5.conf" if os.path.exists(config_file): with open(config_file, "r") as file: config_lines = file.readlines() mtu_set = False for i, line in enumerate(config_lines): if line.strip().startswith("MTU ="): config_lines[i] = f"MTU = {mtu_value}\n" mtu_set = True break if not mtu_set: for i, line in enumerate(config_lines): if line.strip() == "[Interface]": config_lines.insert(i + 1, f"MTU = {mtu_value}\n") break with open(config_file, "w") as file: file.writelines(config_lines) print("\033[92mMTU value updated successfully\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver5.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver5.conf"], check=True ) print("\033[92mWireGuard interface restarted\033[0m") else: print("\033[91mWireGuard configuration file doesn't exist\033[0m") def gre6_kh1tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" if os.path.exists("/etc/gre61.sh"): with open("/etc/gre61.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig61 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig61 mtu" not in line ] with open("/etc/gre61.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre61.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh2tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" if os.path.exists("/etc/gre62.sh"): with open("/etc/gre62.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig62 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig62 mtu" not in line ] with open("/etc/gre62.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre62.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh3tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" if os.path.exists("/etc/gre63.sh"): with open("/etc/gre63.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig63 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig63 mtu" not in line ] with open("/etc/gre63.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre63.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh4tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" if os.path.exists("/etc/gre64.sh"): with open("/etc/gre64.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig64 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig64 mtu" not in line ] with open("/etc/gre64.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre64.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh5tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" if os.path.exists("/etc/gre65.sh"): with open("/etc/gre65.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig65 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig65 mtu" not in line ] with open("/etc/gre65.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre65.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" if os.path.exists("/etc/private1.sh"): with open("/etc/private1.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi1 mtu" not in line ] with open("/etc/private1.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private1.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" if os.path.exists("/etc/private2.sh"): with open("/etc/private2.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi2 mtu" not in line ] with open("/etc/private2.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private2.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" if os.path.exists("/etc/private3.sh"): with open("/etc/private3.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi3 mtu" not in line ] with open("/etc/private3.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private3.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" if os.path.exists("/etc/private4.sh"): with open("/etc/private4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi4 mtu" not in line ] with open("/etc/private4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private4.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" if os.path.exists("/etc/private5.sh"): with open("/etc/private5.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi5 mtu" not in line ] with open("/etc/private5.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private5.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def Wireguard_uninstall(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mWireguard\033[0m") print("2. \033[92mWireguard & GRE6tap\033[0m") print("3. \033[92mWireguard & SIT\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_wireguardudp() break elif server_type == "2": remove_wireguardgre6tap() break elif server_type == "3": remove_wireguardsit() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") config_files = [ "/etc/wireguard/wireserver1.conf", "/etc/wireguard/wireserver2.conf", "/etc/wireguard/wireserver3.conf", "/etc/wireguard/wireserver4.conf", "/etc/wireguard/wireserver5.conf", "/etc/wireguard/wireclient.conf", ] listen_port_pattern = re.compile(r"ListenPort\s*=\s*(\d+)") ipv4_address_pattern = re.compile(r"Address\s*=\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})") ipv6_address_pattern = re.compile(r"Address\s*=\s*([A-Fa-f0-9:]+)") ipv4_allowed_ips_pattern = re.compile( r"AllowedIPs\s*=\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" ) ipv6_allowed_ips_pattern = re.compile(r"AllowedIPs\s*=\s*([A-Fa-f0-9:/]+)") def extract_ufwrules(config_file): listen_port = None addresses = [] with open(config_file, "r") as file: for line in file: if listen_port_match := listen_port_pattern.search(line): listen_port = listen_port_match.group(1) elif ipv4_address_match := ipv4_address_pattern.search(line): addresses.append(ipv4_address_match.group(1)) elif ipv6_address_match := ipv6_address_pattern.search(line): addresses.append(ipv6_address_match.group(1).split("/")[0]) elif ipv4_allowed_ips_match := ipv4_allowed_ips_pattern.search(line): addresses.append(ipv4_allowed_ips_match.group(1)) elif ipv6_allowed_ips_match := ipv6_allowed_ips_pattern.search(line): addresses.append(ipv6_allowed_ips_match.group(1).split("/")[0]) return listen_port, addresses def delete_ufw_rules_uninstall(listen_port, addresses): if listen_port: result = subprocess.run( ["sudo", "ufw", "delete", "allow", f"{listen_port}/udp"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, ) if result.returncode == 0: print(f"\033[92mDeleted UFW rule for port {listen_port}/udp\033[0m") else: print( f"\033[91mfailed to delete UFW rule for port {listen_port}/udp: {result.stderr.decode().strip()}\033[0m" ) for ip in addresses: if ":" in ip: # IPv6 address result = subprocess.run( ["sudo", "ufw", "delete", "allow", "from", ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, ) if result.returncode == 0: print(f"\033[92mDeleted UFW rule for IPv6 address {ip}\033[0m") else: print( f"\033[91mfailed to delete UFW rule for IPv6 address {ip}: {result.stderr.decode().strip()}\033[0m" ) elif "." in ip: # IPv4 address result = subprocess.run( ["sudo", "ufw", "delete", "allow", "from", ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, ) if result.returncode == 0: print(f"\033[92mDeleted UFW rule for IPv4 address {ip}\033[0m") else: print( f"\033[91mfailed to delete UFW rule for IPv4 address {ip}: {result.stderr.decode().strip()}\033[0m" ) else: print(f"\033[91mUnsupported IP address detected: {ip}\033[0m") def remove_wireguardudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs\033[0m") print("2. \033[92mClients\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": server_wireguardudp() break elif server_type == "2": clients_wireguardudp() break elif server_type == "0": os.system("clear") Wireguard_uninstall() break else: print("Invalid choice.") def server_wireguardudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("6. \033[92mall of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": server1_wireguardudp() break elif server_type == "2": server2_wireguardudp() break elif server_type == "3": server3_wireguardudp() break elif server_type == "4": server4_wireguardudp() break elif server_type == "5": server5_wireguardudp() break elif server_type == "6": serverq_wireguardudp() break elif server_type == "0": os.system("clear") remove_wireguardudp() break else: print("Invalid choice.") def serverq_wireguardudp(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mConfigs\033[93m do you want to uninstall?\033[0m " ) ) for i in range(1, num_servers + 1): menu_name = "server{}_wireguardudp".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def clients_wireguardudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard UDP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("6. \033[92mall of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": client1_wireguardudp() break elif server_type == "2": client1_wireguardudp() break elif server_type == "3": client1_wireguardudp() break elif server_type == "4": client1_wireguardudp() break elif server_type == "5": client1_wireguardudp() break elif server_type == "6": client1_wireguardudp() break elif server_type == "0": os.system("clear") remove_wireguardudp() break else: print("Invalid choice.") def server1_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireserver1.conf > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run( "rm /etc/wireguard/wireserver1.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard_1.sh", shell=True) subprocess.run("systemctl disable wireguardping_1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping_1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping_1.service > /dev/null 2>&1", shell=True, ) subprocess.run( "systemctl disable wg-quick@wireserver1 > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireserver1 > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireserver1 down > /dev/null", shell=True) subprocess.run("ip link delete wireserver1 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def server2_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireserver2.conf > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run( "rm /etc/wireguard/wireserver2.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard_2.sh", shell=True) subprocess.run("systemctl disable wireguardping_2 > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping_2 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping_2.service > /dev/null 2>&1", shell=True, ) subprocess.run( "systemctl disable wg-quick@wireserver2 > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireserver2 > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireserver2 down > /dev/null", shell=True) subprocess.run("ip link delete wireserver2 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def server3_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireserver3.conf > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run( "rm /etc/wireguard/wireserver3.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard_3.sh", shell=True) subprocess.run("systemctl disable wireguardping_3 > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping_3 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping_3.service > /dev/null 2>&1", shell=True, ) subprocess.run( "systemctl disable wg-quick@wireserver3 > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireserver3 > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireserver3 down > /dev/null", shell=True) subprocess.run("ip link delete wireserver3 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def server4_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireserver4.conf > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run( "rm /etc/wireguard/wireserver4.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard_4.sh", shell=True) subprocess.run("systemctl disable wireguardping_4 > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping_4 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping_4.service > /dev/null 2>&1", shell=True, ) subprocess.run( "systemctl disable wg-quick@wireserver4 > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireserver4 > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireserver4 down > /dev/null", shell=True) subprocess.run("ip link delete wireserver4 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def server5_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireserver5.conf > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run( "rm /etc/wireguard/wireserver5.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard_5.sh", shell=True) subprocess.run("systemctl disable wireguardping_5 > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping_5 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping_5.service > /dev/null 2>&1", shell=True, ) subprocess.run( "systemctl disable wg-quick@wireserver5 > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireserver5 > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireserver5 down > /dev/null", shell=True) subprocess.run("ip link delete wireserver5 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def client1_wireguardudp(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mWireguard\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") for config_file in config_files: if os.path.exists(config_file): print(f"Processing {config_file}...") print("\033[93m───────────────────────────────────────\033[0m") listen_port, addresses = extract_ufwrules(config_file) delete_ufw_rules_uninstall(listen_port, addresses) try: if ( subprocess.call( "test -f /etc/wireguard/wireclient.conf > /dev/null 2>&1", shell=True, ) == 0 ): subprocess.run( "rm /etc/wireguard/wireclient.conf > /dev/null 2>&1", shell=True ) display_notification("\033[93mRemoving stuff...\033[0m") subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_wireguard.sh", shell=True) subprocess.run("systemctl disable wireguardping > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop wireguardping > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/wireguardping.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable wg-quick@wireclient > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop wg-quick@wireclient > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev wireclient down > /dev/null", shell=True) subprocess.run("ip link delete wireclient > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def delufw(ip_address): subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip_address]) # requirement for gre6tap def remove_gretap61_server1(): os.system("clear") server1_wireguardudp() delufw("2002:801a::2") delufw("2002:801a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip link delete azumig61 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap62_server2(): os.system("clear") server2_wireguardudp() delufw("2002:811a::2") delufw("2002:811a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip link delete azumig62 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap63_server3(): os.system("clear") server3_wireguardudp() delufw("2002:821a::2") delufw("2002:821a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip link delete azumig63 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap64_server4(): os.system("clear") server4_wireguardudp() delufw("2002:831a::2") delufw("2002:831a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip link delete azumig64 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap65_server5(): os.system("clear") server5_wireguardudp() delufw("2002:841a::2") delufw("2002:841a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip link delete azumig65 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # client def remove_gretap61_client1(): os.system("clear") client1_wireguardudp() delufw("2002:801a::2") delufw("2002:801a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip link delete azumig61 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap62_client2(): os.system("clear") client1_wireguardudp() delufw("2002:811a::2") delufw("2002:811a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip link delete azumig62 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap63_client3(): os.system("clear") client1_wireguardudp() delufw("2002:821a::2") delufw("2002:821a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip link delete azumig63 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap64_client4(): os.system("clear") client1_wireguardudp() delufw("2002:831a::2") delufw("2002:831a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip link delete azumig64 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap65_client5(): os.system("clear") client1_wireguardudp() delufw("2002:841a::2") delufw("2002:841a::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip link delete azumig65 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_wireguardgre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard & GRE6TAP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs\033[0m") print("2. \033[92mClients\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": server_wireguardgre6tap() break elif server_type == "2": clients_wireguardgre6tap() break elif server_type == "0": os.system("clear") Wireguard_uninstall() break else: print("Invalid choice.") def server_wireguardgre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard GRE6TAP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_server1() break elif server_type == "2": remove_gretap62_server2() break elif server_type == "3": remove_gretap63_server3() break elif server_type == "4": remove_gretap64_server4() break elif server_type == "5": remove_gretap65_server5() break elif server_type == "0": os.system("clear") remove_wireguardgre6tap() break else: print("Invalid choice.") def clients_wireguardgre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard GRE5TAP Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_client1() break elif server_type == "2": remove_gretap62_client2() break elif server_type == "3": remove_gretap63_client3() break elif server_type == "4": remove_gretap64_client4() break elif server_type == "5": remove_gretap65_client5() break elif server_type == "0": os.system("clear") remove_wireguardgre6tap() break else: print("Invalid choice.") # requirement for sit def remove_sit1_server1(): os.system("clear") server1_wireguardudp() delufw("2002:801b::2") delufw("2002:801b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip link delete azumi1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit2_server2(): os.system("clear") server2_wireguardudp() delufw("2002:811b::2") delufw("2002:811b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip link delete azumi2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit3_server3(): os.system("clear") server3_wireguardudp() delufw("2002:821b::2") delufw("2002:821b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip link delete azumi3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit4_server4(): os.system("clear") server4_wireguardudp() delufw("2002:831b::2") delufw("2002:831b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip link delete azumi4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit5_server5(): os.system("clear") server5_wireguardudp() delufw("2002:841b::2") delufw("2002:841b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip link delete azumi5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # client def remove_sit1_client1(): os.system("clear") client1_wireguardudp() delufw("2002:801b::2") delufw("2002:801b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip link delete azumi1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit2_client2(): os.system("clear") client1_wireguardudp() delufw("2002:811b::2") delufw("2002:811b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip link delete azumi2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit3_client3(): os.system("clear") client1_wireguardudp() delufw("2002:821b::2") delufw("2002:821b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip link delete azumi3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit4_client4(): os.system("clear") client1_wireguardudp() delufw("2002:831b::2") delufw("2002:831b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip link delete azumi4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_sit5_client5(): os.system("clear") client1_wireguardudp() delufw("2002:841b::2") delufw("2002:841b::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mSit\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving stuff..\033[0m") subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip link delete azumi5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_wireguardsit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard & SIT Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs\033[0m") print("2. \033[92mClients\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": server_wireguardsit() break elif server_type == "2": clients_wireguardsit() break elif server_type == "0": os.system("clear") Wireguard_uninstall() break else: print("Invalid choice.") def server_wireguardsit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard SIT Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer Configs [1]\033[0m") print("2. \033[93mServer Configs [2]\033[0m") print("3. \033[92mServer Configs [3]\033[0m") print("4. \033[93mServer Configs [4]\033[0m") print("5. \033[93mServer Configs [5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_sit1_server1() break elif server_type == "2": remove_sit2_server2() break elif server_type == "3": remove_sit3_server3() break elif server_type == "4": remove_sit4_server4() break elif server_type == "5": remove_sit5_server5() break elif server_type == "0": os.system("clear") remove_wireguardsit() break else: print("Invalid choice.") def clients_wireguardsit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard SIT Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mClient [1]\033[0m") print("2. \033[93mClient [2]\033[0m") print("3. \033[92mClient [3]\033[0m") print("4. \033[93mClient [4]\033[0m") print("5. \033[93mClient [5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_sit1_client1() break elif server_type == "2": remove_sit2_client2() break elif server_type == "3": remove_sit3_client3() break elif server_type == "4": remove_sit4_client4() break elif server_type == "5": remove_sit5_client5() break elif server_type == "0": os.system("clear") remove_wireguardsit() break else: print("Invalid choice.") def wireguard_edit_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard Edit local\033[97mMenu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard UDP\033[0m") print("2. \033[93mSit + Wireguard\033[0m") print("3. \033[92mGre6tap [Native] + Wireguard\033[0m") print("4. \033[93mWireguard + Gre6tap\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardeditserver_mnu() break elif server_type == "2": wireguardsiteditserver_mnu() break elif server_type == "3": gre6tapwireguardeditserver_mnu() break elif server_type == "4": wireguardgre6tapeditserver_mnu() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") def wireguardeditserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardeditserver_nosec_mnu() break elif server_type == "2": wireguardeditserver_sec_mnu() break elif server_type == "0": os.system("clear") wireguard_edit_server() break else: print("Invalid choice.") def wireguardeditserver_nosec_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_noconjuction_kharej1_5iran() break elif server_type == "2": wireguardedit_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardedit_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_iran_client1() break elif server_type == "2": wireguardudp_iran_client2() break elif server_type == "3": wireguardudp_iran_client3() break elif server_type == "4": wireguardudp_iran_client4() break elif server_type == "5": wireguardudp_iran_client5() break elif server_type == "6": wireguardudpedit_kharej_server() break elif server_type == "0": os.system("clear") wireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardudpedit_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_kharejconfig_1() break elif server_type == "2": wireguardedit_kharejconfig_2() break elif server_type == "3": wireguardedit_kharejconfig_3() break elif server_type == "4": wireguardedit_kharejconfig_4() break elif server_type == "5": wireguardedit_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_kharej1_5iran() break else: print("Invalid choice.") def wtb_opposite_ip_wireguard(ip): if ":" in ip: ip_parts = ip.split(":") if ip_parts[-1] == "1": ip_parts[-1] = "2" elif ip_parts[-1] == "2": ip_parts[-1] = "1" else: ip_parts[-1] = "2" return ":".join(ip_parts) else: ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def load_wireguardconfig(file_path): try: with open(file_path, "r") as file: content = file.read() address_match = re.search(r"Address = ([^\s]+)", content) listen_port_match = re.search(r"ListenPort = (\d+)", content) endpoint_match = re.search(r"Endpoint = ([^\s]+):\d+", content) allowed_ips_match = re.search(r"AllowedIPs = ([^\s]+)", content) address = address_match.group(1) if address_match else "N/A" listen_port = listen_port_match.group(1) if listen_port_match else "N/A" endpoint = endpoint_match.group(1) if endpoint_match else "N/A" allowed_ips = allowed_ips_match.group(1) if allowed_ips_match else "N/A" return address, address.split("/")[0], listen_port, endpoint, allowed_ips except FileNotFoundError: print("\033[91mWireGuard configuration file not found.\033[0m") return None, None, None, None, None except Exception as e: print(f"\033[91mAn error occurred: {e}\033[0m") return None, None, None, None, None def display_checkmark(message): print("\u2714 " + message) def save_wireguardconfig1(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_1.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver1.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver1.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig2(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_2.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver2.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver2.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig3(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_3.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver3.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver3.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig4(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_4.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver4.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver4.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig5(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_5.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver5.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver5.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireclient.conf"], check=True ) subprocess.run(["wg-quick", "up", "/etc/wireguard/wireclient.conf"], check=True) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restarting services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def update_ufw_ruleswireguard(old_ip, new_ip, old_port=None, new_port=None): if old_port: delete_ufw_rules(old_ip, old_port) delete_ufw_rules(wtb_opposite_ip_wireguard(old_ip), old_port) add_ufw_ruleswireguard(new_ip, new_port) add_ufw_ruleswireguard(wtb_opposite_ip_wireguard(new_ip), new_port) def delete_ufw_rules(ip, port): try: subprocess.run( ["sudo", "ufw", "delete", "allow", "from", ip, "to", "any", "port", port], check=False, ) except subprocess.CalledProcessError as e: print(f"\033[91mError deleting UFW rule for {ip} on port {port}: {e}\033[0m") def add_ufw_ruleswireguard(ip, port): try: subprocess.run( ["sudo", "ufw", "allow", "from", ip, "to", "any", "port", port], check=True ) except subprocess.CalledProcessError as e: print(f"\033[91mError adding UFW rule for {ip} on port {port}: {e}\033[0m") def display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips): lines = [ f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mTitle: Wireguard Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mAddress: \033[97m{address_no_subnet}\033[0m", f"\033[92mListenPort: \033[97m{listen_port}\033[0m", f"\033[92mEndpoint: \033[97m{endpoint}\033[0m", f"\033[92mAllowedIPs: \033[97m{allowed_ips}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ping_script_opposite_ip_wirenosec_client(new_opposite_ip): script_path = "/etc/ping_wireguard.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec1(new_opposite_ip): script_path = "/etc/ping_wireguard_1.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec2(new_opposite_ip): script_path = "/etc/ping_wireguard_2.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec3(new_opposite_ip): script_path = "/etc/ping_wireguard_3.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec4(new_opposite_ip): script_path = "/etc/ping_wireguard_4.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec5(new_opposite_ip): script_path = "/etc/ping_wireguard_5.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def listen_port(config_path): """Extracts the ListenPort from the WireGuard configuration file.""" try: with open(config_path, "r") as file: content = file.read() match = re.search(r"^ListenPort\s*=\s*(\d+)", content, re.MULTILINE) if match: return match.group(1) else: print("\033[91mPort not found in the config file.\033[0m") return "51820" except FileNotFoundError: print(f"\033[91mError: Configuration file '{config_path}' not found.\033[0m") return "51820" def update_endpoint_ip1(endpoint, config_path="/etc/wireguard/wireserver1.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Client [1]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ip2(endpoint, config_path="/etc/wireguard/wireserver2.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Client [2]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ip3(endpoint, config_path="/etc/wireguard/wireserver3.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Client [3]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ip4(endpoint, config_path="/etc/wireguard/wireserver4.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Client [4]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ip5(endpoint, config_path="/etc/wireguard/wireserver5.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Client [5]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ip_server(endpoint, config_path="/etc/wireguard/wireclient.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Server) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_tunnel_port(listen_port, endpoint): new_port = input( f"\033[93mEnter \033[92mNew Tunnel Port \033[93m({listen_port}): \033[0m" ) if new_port.isdigit(): if ":" in endpoint: endpoint_ip, _ = endpoint.split(":") else: endpoint_ip = endpoint new_endpoint = f"{endpoint_ip}:{new_port}" return new_port, new_endpoint else: print("\033[91mInvalid Port!\033[0m") return listen_port, endpoint def update_endpoint_ir_ip1(endpoint, config_path="/etc/wireguard/wireserver1.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Client [1]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ir_ip2(endpoint, config_path="/etc/wireguard/wireserver2.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Client [2]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ir_ip3(endpoint, config_path="/etc/wireguard/wireserver3.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Client [3]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ir_ip4(endpoint, config_path="/etc/wireguard/wireserver4.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Client [4]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ir_ip5(endpoint, config_path="/etc/wireguard/wireserver5.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(Kharej Client [5]) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def update_endpoint_ir_server(endpoint, config_path="/etc/wireguard/wireclient.conf"): default_port = listen_port(config_path) if ":" in endpoint: current_ip, current_port = endpoint.split(":") else: current_ip = endpoint current_port = default_port new_endpoint_ip = input( f"\033[93mEnter\033[92m New Endpoint IP \033[97m(IRAN Server) \033[93m({current_ip}): \033[0m" ) if new_endpoint_ip: new_endpoint = f"{new_endpoint_ip}:{current_port}" return new_endpoint else: print("\033[91mNo IP entered, keeping the existing Endpoint unchanged\033[0m") return endpoint def wireguardedit_kharejconfig_1(): config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Client [1]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip1(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig1(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_kharejconfig_2(): config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Client [2]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip2(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig2(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_kharejconfig_3(): config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Client [3]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip3(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig3(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_kharejconfig_4(): config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Client [4]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip4(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig4(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_kharejconfig_5(): config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Client [5]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip5(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig5(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client1(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client2(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client3(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client4(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client5(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_kharej_client1() break elif server_type == "2": wireguardudp_kharej_client2() break elif server_type == "3": wireguardudp_kharej_client3() break elif server_type == "4": wireguardudp_kharej_client4() break elif server_type == "5": wireguardudp_kharej_client5() break elif server_type == "6": wireguardudpedit_iran_server() break elif server_type == "0": os.system("clear") wireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardudpedit_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Server Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_iranconfig_1() break elif server_type == "2": wireguardedit_iranconfig_2() break elif server_type == "3": wireguardedit_iranconfig_3() break elif server_type == "4": wireguardedit_iranconfig_4() break elif server_type == "5": wireguardedit_iranconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_1iran_5kharej() break else: print("Invalid choice.") def wireguardedit_iranconfig_1(): config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [1]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip1(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig1(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_2(): config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [2]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip2(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig2(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_3(): config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [3]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip3(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig3(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_4(): config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [4]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip4(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig4(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_5(): config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m IRAN Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [5]\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip5(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig5(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client1(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client2(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client3(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client4(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client5(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard Edit local\033[97m Kharej Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[96m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mIRAN Server\033[93m IP \033[96m(Endpoint IP)\033[0m" ) print("4.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(config_path, new_config) break elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") # wireguard ipsec def wireguardeditserver_sec_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + IPSEC \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_noconjuction_kharej1_5iransec() break elif server_type == "2": wireguardedit_noconjuction_1iran_5kharejsec() break elif server_type == "0": os.system("clear") wireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardedit_noconjuction_kharej1_5iransec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_iran_client1sec() break elif server_type == "2": wireguardudp_iran_client2sec() break elif server_type == "3": wireguardudp_iran_client3sec() break elif server_type == "4": wireguardudp_iran_client4sec() break elif server_type == "5": wireguardudp_iran_client5sec() break elif server_type == "6": wireguardudpedit_kharej_serversec() break elif server_type == "0": os.system("clear") wireguardeditserver_sec_mnu() break else: print("Invalid choice.") def wireguardudpedit_kharej_serversec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_kharejconfig_1sec() break elif server_type == "2": wireguardedit_kharejconfig_2sec() break elif server_type == "3": wireguardedit_kharejconfig_3sec() break elif server_type == "4": wireguardedit_kharejconfig_4sec() break elif server_type == "5": wireguardedit_kharejconfig_5sec() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_kharej1_5iransec() break else: print("Invalid choice.") def wireguardedit_noconjuction_1iran_5kharejsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_kharej_client1sec() break elif server_type == "2": wireguardudp_kharej_client2sec() break elif server_type == "3": wireguardudp_kharej_client3sec() break elif server_type == "4": wireguardudp_kharej_client4sec() break elif server_type == "5": wireguardudp_kharej_client5sec() break elif server_type == "6": wireguardudpedit_iran_serversec() break elif server_type == "0": os.system("clear") wireguardeditserver_sec_mnu() break else: print("Invalid choice.") def wireguardudpedit_iran_serversec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + IPSEC \033[92mIRAN Server Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_iranconfig_1sec() break elif server_type == "2": wireguardedit_iranconfig_2sec() break elif server_type == "3": wireguardedit_iranconfig_3sec() break elif server_type == "4": wireguardedit_iranconfig_4sec() break elif server_type == "5": wireguardedit_iranconfig_5sec() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_1iran_5kharejsec() break else: print("Invalid choice.") def wtb_opposite_ip_wireguardsec(ip): if ":" in ip: ip_parts = ip.split(":") if ip_parts[-1] == "1": ip_parts[-1] = "2" elif ip_parts[-1] == "2": ip_parts[-1] = "1" else: ip_parts[-1] = "2" return ":".join(ip_parts) else: ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def load_wireguardconfigsec(file_path): try: with open(file_path, "r") as file: content = file.read() address_match = re.search(r"Address = ([^\s]+)", content) listen_port_match = re.search(r"ListenPort = (\d+)", content) endpoint_match = re.search(r"Endpoint = ([^\s]+):\d+", content) allowed_ips_match = re.search(r"AllowedIPs = ([^\s]+)", content) address = address_match.group(1) if address_match else "N/A" listen_port = listen_port_match.group(1) if listen_port_match else "N/A" endpoint = endpoint_match.group(1) if endpoint_match else "N/A" allowed_ips = allowed_ips_match.group(1) if allowed_ips_match else "N/A" return address, address.split("/")[0], listen_port, endpoint, allowed_ips except FileNotFoundError: print("\033[91mWireguard configuration file not found\033[0m") return None, None, None, None, None except Exception as e: print(f"\033[91mAn error occurred: {e}\033[0m") return None, None, None, None, None def save_wireguardconfigsec1(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_1.service", ] wg_quick_interface = "/etc/wireguard/wireserver1.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfigsec2(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_2.service", ] wg_quick_interface = "/etc/wireguard/wireserver2.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfigsec3(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_3.service", ] wg_quick_interface = "/etc/wireguard/wireserver3.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfigsec4(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_4.service", ] wg_quick_interface = "/etc/wireguard/wireserver4.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfigsec5(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_5.service", ] wg_quick_interface = "/etc/wireguard/wireserver5.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfigsec_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+:\d+)?" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) existing_endpoint_match = re.search(endpoint_pattern, config) if existing_endpoint_match: existing_endpoint = existing_endpoint_match.group(1) if ":" not in new_config["Endpoint"]: new_config["Endpoint"] += f":{existing_endpoint.split(':')[1]}" new_config_content = re.sub( endpoint_pattern, f'Endpoint = {new_config["Endpoint"]}', new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping.service", ] wg_quick_interface = "/etc/wireguard/wireclient.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def update_ufw_ruleswireguardsec(old_ip, new_ip, old_port=None, new_port=None): if old_port: delete_ufw_rulessec(old_ip, old_port) delete_ufw_rulessec(wtb_opposite_ip_wireguardsec(old_ip), old_port) add_ufw_ruleswireguardsec(new_ip, new_port) add_ufw_ruleswireguardsec(wtb_opposite_ip_wireguardsec(new_ip), new_port) def delete_ufw_rulessec(ip, port): try: subprocess.run( ["sudo", "ufw", "delete", "allow", "from", ip, "to", "any", "port", port], check=False, ) except subprocess.CalledProcessError as e: print(f"\033[91mError deleting UFW rule for {ip} on port {port}: {e}\033[0m") def add_ufw_ruleswireguardsec(ip, port): try: subprocess.run( ["sudo", "ufw", "allow", "from", ip, "to", "any", "port", port], check=True ) except subprocess.CalledProcessError as e: print(f"\033[91mError adding UFW rule for {ip} on port {port}: {e}\033[0m") def display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips): lines = [ f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mTitle: Wireguard Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mAddress: \033[97m{address_no_subnet}\033[0m", f"\033[92mListenPort: \033[97m{listen_port}\033[0m", f"\033[92mEndpoint: \033[97m{endpoint}\033[0m", f"\033[92mAllowedIPs: \033[97m{allowed_ips}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ping_script_opposite_ip_wireguard1(new_opposite_ip): script_path = "/etc/ping_wireguard_1.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wireguard_client(new_opposite_ip): script_path = "/etc/ping_wireguard.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wireguard2(new_opposite_ip): script_path = "/etc/ping_wireguard_2.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wireguard3(new_opposite_ip): script_path = "/etc/ping_wireguard_3.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wireguard4(new_opposite_ip): script_path = "/etc/ping_wireguard_4.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wireguard5(new_opposite_ip): script_path = "/etc/ping_wireguard_5.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def ipsecsecret_key_wire(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mNo IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") return None def update_ipsecsecret_wire(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) display_checkmark("\033[92mIPsec secret key updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_46(name, new_private_ip): try: with open(name, "r") as f: content = f.read() if ":" in new_private_ip: ip_parts = new_private_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1].endswith("2") else "2" counterpart_ip = ":".join(ip_parts) subnet_suffix = "/64" else: ip_parts = new_private_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) subnet_suffix = "/24" new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet_suffix}", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet_suffix}", new_content, ) with open(name, "w") as f: f.write(new_content) display_checkmark("\033[92mIPsec configuration updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def display_ipsecsecret_wire(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_ip_wire(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") parts[-1] = "1" if parts[-1].endswith("2") else "2" return ":".join(parts) else: octets = ip.split(".") octets[-1] = "1" if octets[-1] == "2" else "2" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) try: with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] for line in lines: if ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) display_checkmark("\033[92mIPsec secrets updated successfully!\033[0m") except FileNotFoundError: print("\033[91mFile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wireguardedit_kharejconfig_1sec(): config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Client [1] \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip1(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec1(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iransec() else: print("\033[91mPlease select a valid option.\033[0m") def update_ipsec_conf_wireguard_server2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wireguardedit_kharejconfig_2sec(): config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Client [2] \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip2(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec2(config_path, new_config) update_ipsec_ip_multi2(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iransec() else: print("\033[91mPlease select a valid option.\033[0m") def update_ipsec_conf_wireguard_server3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wireguardedit_kharejconfig_3sec(): config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change IRAN Client [3] \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip3(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec3(config_path, new_config) update_ipsec_ip_multi3(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iransec() else: print("\033[91mPlease select a valid option.\033[0m") def update_ipsec_conf_wireguard_server4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wireguardedit_kharejconfig_4sec(): config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change IRAN Client [4] \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip4(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec4(config_path, new_config) update_ipsec_ip_multi4(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iransec() else: print("\033[91mPlease select a valid option.\033[0m") def update_ipsec_conf_wireguard_server5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wireguardedit_kharejconfig_5sec(): config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Server - \033[97mConfig [5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change IRAN Client [5] \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip5(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec5(config_path, new_config) update_ipsec_ip_multi5(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iransec() else: print("\033[91mPlease select a valid option.\033[0m") def save_wireguardconfigsec_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint_port(match): endpoint_ip = match.group(1) return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint_port, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping.service", ] wg_quick_interface = "/etc/wireguard/wireclient.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def update_ipsec_conf_wireguard_46(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_obj = ipaddress.ip_address(new_private_ip) if isinstance(ip_obj, ipaddress.IPv6Address): ip_parts = new_private_ip.split(":") subnet_suffix = "/64" else: ip_parts = new_private_ip.split(".") subnet_suffix = "/32" ip_parts[-1] = "1" if ip_parts[-1].endswith("2") else "2" counterpart_ip = ( ":".join(ip_parts) if isinstance(ip_obj, ipaddress.IPv6Address) else ".".join(ip_parts) ) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet_suffix}", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet_suffix}", new_content, ) with open(name, "w") as f: f.write(new_content) print("\033[92mIPsec configuration updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def wireguardudp_iran_client1sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mKharej Server IP\033[96m (Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client2sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mKharej Server IP\033[96m (Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client3sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mKharej Server IP\033[96m (Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client4sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mKharej Server IP\033[96m (Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_iran_client5sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Client - \033[97m[5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mKharej Server IP\033[96m (Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ip_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_kharej1_5iran() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_1sec(): config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [1] \033[96m(Endpoint IP)\033[0m" ) print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip1(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec1(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharejsec() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_2sec(): config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [2] \033[96m(Endpoint IP)\033[0m" ) print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip2(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec2(config_path, new_config) update_ipsec_ip_multi2(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharejsec() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_3sec(): config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [3] \033[96m(Endpoint IP)\033[0m" ) print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip3(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec3(config_path, new_config) update_ipsec_ip_multi3(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharejsec() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_4sec(): config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [4] \033[96m(Endpoint IP)\033[0m" ) print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip4(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec4(config_path, new_config) update_ipsec_ip_multi4(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharejsec() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardedit_iranconfig_5sec(): config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m IRAN Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN Server - \033[97mConfig [5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print( "3.\033[93m Change \033[92mKharej Client [5] \033[96m(Endpoint IP)\033[0m" ) print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_ip5(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec5(config_path, new_config) update_ipsec_ip_multi5(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharejsec() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client1sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[1]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client2sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[2]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client3sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[3]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client4sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[4]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") def wireguardudp_kharej_client5sec(): config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfigsec(config_path) ) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + IPSEC Edit local\033[97m Kharej Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Client - \033[97m[5]\033[0m") print("1.\033[92m Change \033[97mPrivate IP\033[92m Address\033[0m") print("2.\033[94m Change Tunnel Port\033[0m") print("3.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("4.\033[94m Change IPsec Secret Key\033[0m") print("5.\033[92m Save and Exit\033[0m") print("0. back to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input( "\033[93mEnter\033[92m New Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguardsec(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguardsec(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wireguard_client(opposite_ip) update_ipsec_conf_wireguard_46("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "2": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "3": endpoint = update_endpoint_ir_server(endpoint) elif choice == "4": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(config_path, new_config) update_ipsec_ip(new_ip) return elif choice == "0": wireguardedit_noconjuction_1iran_5kharej() else: print("\033[91mPlease select a valid option.\033[0m") # wire + gre6tap def private_native(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumi?", content) if match: return match.group(1) else: print("\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_native_ipsgretap61(): private_ip_gre6 = private_gre61("/etc/gre61.sh") return { "gre6": private_ip_gre6, } def get_current_native_ipsgretap62(): private_ip_gre6 = private_gre61("/etc/gre62.sh") return { "gre6": private_ip_gre6, } def get_current_native_ipsgretap63(): private_ip_gre6 = private_gre6tap("/etc/gre63.sh") return { "gre6": private_ip_gre6, } def get_current_native_ipsgretap64(): private_ip_gre6 = private_gre6tap("/etc/gre64.sh") return { "gre6": private_ip_gre6, } def get_current_native_ipsgretap65(): private_ip_gre6 = private_gre6tap("/etc/gre65.sh") return { "gre6": private_ip_gre6, } def update_pingfile_sit(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire1("/etc/gre61.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire2("/etc/gre62.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire3("/etc/gre63.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire4("/etc/gre64.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire5("/etc/gre65.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules(ip, port=None): counterpart_ip = wtb_opposite_ip_sitwire(ip) try: if port: subprocess.run( ["sudo", "ufw", "allow", "from", ip, "to", "any", "port", port], check=True, ) subprocess.run( [ "sudo", "ufw", "allow", "from", counterpart_ip, "to", "any", "port", port, ], check=True, ) else: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip_sitwire(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def save_stuff_gretap61(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgretap61() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_gre6_wire1("/etc/gre61.sh", private_ip, update_type="private") update_ipfile_gre6_wire1("/etc/gre61.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_gre6_wire1( "/etc/private1.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_gre6_wire1( "/etc/private1.sh", remote_ip, update_type="remote" ) interface = "azumig61" if is_gre6 else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gretap62(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgretap62() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_gre6_wire2("/etc/gre62.sh", private_ip, update_type="private") update_ipfile_gre6_wire2("/etc/gre62.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_gre6_wire2( "/etc/private2.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_gre6_wire2( "/etc/private2.sh", remote_ip, update_type="remote" ) interface = "azumig62" if is_gre6 else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gretap63(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgretap63() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_gre6_wire3("/etc/gre63.sh", private_ip, update_type="private") update_ipfile_gre6_wire3("/etc/gre63.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_gre6_wire3( "/etc/private3.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_gre6_wire3( "/etc/private3.sh", remote_ip, update_type="remote" ) interface = "azumig63" if is_gre6 else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gretap64(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgretap64() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_gre6_wire4("/etc/gre64.sh", private_ip, update_type="private") update_ipfile_gre6_wire4("/etc/gre64.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_gre6_wire4( "/etc/private4.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_gre6_wire4( "/etc/private4.sh", remote_ip, update_type="remote" ) interface = "azumig64" if is_gre6 else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gretap65(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgretap65() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_gre6_wire5("/etc/gre65.sh", private_ip, update_type="private") update_ipfile_gre6_wire5("/etc/gre65.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_gre6_wire5( "/etc/private5.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_gre6_wire5( "/etc/private5.sh", remote_ip, update_type="remote" ) interface = "azumig65" if is_gre6 else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def private_gre6tap(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumig6?", content) if match: return match.group(1) else: print("\033[91mNo private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") return None def display_stuff_gre6tapn(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def wireguardgre6tapeditserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Wireguard + GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": wireguardgre6tap_nosec_edit_local() break elif choice == "2": wireguardgre6tap_sec_edit_local() break elif choice == "3": clear() wireguard_edit_server() break else: print("Invalid choice.") def wireguardgre6tap_nosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6TAP\033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard + GRE6TAP - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard + GRE6TAP - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tap_noconjuction_kharej1_5iran() break elif server_type == "2": wireguard_gre6tap_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguardgre6tapeditserver_mnu() break else: print("Invalid choice.") def wireguard_gre6tap_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapn_kharej_client1() break elif server_type == "2": wireguardafter_gre6tapn_kharej_client2() break elif server_type == "3": wireguardafter_gre6tapn_kharej_client3() break elif server_type == "4": wireguardafter_gre6tapn_kharej_client4() break elif server_type == "5": wireguardafter_gre6tapn_kharej_client5() break elif server_type == "6": wireguardafter_gre6tapn_iran_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_nosec_edit_local() break else: print("Invalid choice.") def wireguardafter_gre6tapn_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapn_iranconfig_1() break elif server_type == "2": wireguardafter_gre6tapn_iranconfig_2() break elif server_type == "3": wireguardafter_gre6tapn_iranconfig_3() break elif server_type == "4": wireguardafter_gre6tapn_iranconfig_4() break elif server_type == "5": wireguardafter_gre6tapn_iranconfig_5() break elif server_type == "0": os.system("clear") wireguard_gre6tap_noconjuction_1iran_5kharej() break else: print("Invalid choice.") def wireguard_gre6tap_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapn_iran_client1() break elif server_type == "2": wireguardafter_gre6tapn_iran_client2() break elif server_type == "3": wireguardafter_gre6tapn_iran_client3() break elif server_type == "4": wireguardafter_gre6tapn_iran_client4() break elif server_type == "5": wireguardafter_gre6tapn_iran_client5() break elif server_type == "6": wireguardafter_gre6tapn_kharej_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_nosec_edit_local() break else: print("Invalid choice.") def wireguardafter_gre6tapn_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapn_kharejconfig_1() break elif server_type == "2": wireguardafter_gre6tapn_kharejconfig_2() break elif server_type == "3": wireguardafter_gre6tapn_kharejconfig_3() break elif server_type == "4": wireguardafter_gre6tapn_kharejconfig_4() break elif server_type == "5": wireguardafter_gre6tapn_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("Invalid choice.") # gre6tap ipsec menu def wireguardgre6tap_sec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6TAP + IPSEC\033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard + GRE6TAP - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard + GRE6TAP - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break elif server_type == "2": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguardgre6tapeditserver_mnu() break else: print("Invalid choice.") def wireguard_gre6tapsec_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapnsec_kharej_client1() break elif server_type == "2": wireguardafter_gre6tapnsec_kharej_client2() break elif server_type == "3": wireguardafter_gre6tapnsec_kharej_client3() break elif server_type == "4": wireguardafter_gre6tapnsec_kharej_client4() break elif server_type == "5": wireguardafter_gre6tapnsec_kharej_client5() break elif server_type == "6": wireguardafter_gre6tapnsec_iran_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_sec_edit_local() break else: print("Invalid choice.") def wireguardafter_gre6tapnsec_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapnsec_iranconfig_1() break elif server_type == "2": wireguardafter_gre6tapnsec_iranconfig_2() break elif server_type == "3": wireguardafter_gre6tapnsec_iranconfig_3() break elif server_type == "4": wireguardafter_gre6tapnsec_iranconfig_4() break elif server_type == "5": wireguardafter_gre6tapnsec_iranconfig_5() break elif server_type == "0": os.system("clear") wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Invalid choice.") def wireguard_gre6tapsec_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapnsec_iran_client1() break elif server_type == "2": wireguardafter_gre6tapnsec_iran_client2() break elif server_type == "3": wireguardafter_gre6tapnsec_iran_client3() break elif server_type == "4": wireguardafter_gre6tapnsec_iran_client4() break elif server_type == "5": wireguardafter_gre6tapnsec_iran_client5() break elif server_type == "6": wireguardafter_gre6tapnsec_kharej_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_sec_edit_local() break else: print("Invalid choice.") def wireguardafter_gre6tapnsec_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6TAP IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardafter_gre6tapnsec_kharejconfig_1() break elif server_type == "2": wireguardafter_gre6tapnsec_kharejconfig_2() break elif server_type == "3": wireguardafter_gre6tapnsec_kharejconfig_3() break elif server_type == "4": wireguardafter_gre6tapnsec_kharejconfig_4() break elif server_type == "5": wireguardafter_gre6tapnsec_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Invalid choice.") def wireguardafter_gre6tapn_kharejconfig_1(): wireguard_config_path = "/etc/wireguard/wireserver1.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [1] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip1(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig1(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharejconfig_2(): wireguard_config_path = "/etc/wireguard/wireserver2.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [2] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip2(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig2(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharejconfig_3(): wireguard_config_path = "/etc/wireguard/wireserver3.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [3] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip3(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig3(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharejconfig_4(): wireguard_config_path = "/etc/wireguard/wireserver4.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [4] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip4(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig4(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharejconfig_5(): wireguard_config_path = "/etc/wireguard/wireserver5.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [5] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip5(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig5(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iran_client1(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iran_client2(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iran_client3(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iran_client4(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iran_client5(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") # 1 iran 5 kharej client def wireguardafter_gre6tapn_iranconfig_1(): wireguard_config_path = "/etc/wireguard/wireserver1.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [1] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip1(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig1(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iranconfig_2(): wireguard_config_path = "/etc/wireguard/wireserver2.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [2] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip2(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig2(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iranconfig_3(): wireguard_config_path = "/etc/wireguard/wireserver3.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [3] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip3(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig3(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iranconfig_4(): wireguard_config_path = "/etc/wireguard/wireserver4.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [4] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip4(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig4(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_iranconfig_5(): wireguard_config_path = "/etc/wireguard/wireserver5.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m IRAN Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [5] IP \033[96m(Endpoint IP)\033[0m" ) print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip5(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig5(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharej_client1(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharej_client2(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharej_client3(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharej_client4(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapn_kharej_client5(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP\033[97m Kharej Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfig_client(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": wireguard_gre6tap_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") # gre6tap ipsec def update_ipsec_conf_wireguard_gre6tapserver1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE61": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE61' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE61' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_gre6tapserver2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE62": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE62' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE62' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_gre6tapserver3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE63": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE63' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE63' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_gre6tapserver4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE64": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE64' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE64' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_gre6tapserver5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE65": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE65' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE65' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_gre6tap(name, new_private_ip): try: with open(name, "r") as f: content = f.read() if ":" in new_private_ip: ip_parts = new_private_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1].endswith("2") else "2" counterpart_ip = ":".join(ip_parts) subnet_suffix = "/64" else: ip_parts = new_private_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) subnet_suffix = "/24" new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet_suffix}", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet_suffix}", new_content, ) with open(name, "w") as f: f.write(new_content) display_checkmark("\033[92mIPsec configuration updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def wireguardafter_gre6tapnsec_kharejconfig_1(): wireguard_config_path = "/etc/wireguard/wireserver1.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [1] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver1( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip1(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec1(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharejconfig_2(): wireguard_config_path = "/etc/wireguard/wireserver2.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [2] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver2( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip2(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec2(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi2(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharejconfig_3(): wireguard_config_path = "/etc/wireguard/wireserver3.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [3] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver3( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip3(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec3(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi3(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharejconfig_4(): wireguard_config_path = "/etc/wireguard/wireserver4.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [4] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver4( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip4(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec4(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi4(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharejconfig_5(): wireguard_config_path = "/etc/wireguard/wireserver5.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Server \033[97mConfig [5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mIRAN Client [5] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver5( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip5(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec5(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi5(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iran_client1(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iran_client2(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iran_client3(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iran_client4(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iran_client5(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Client \033[97m[5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mKharej Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ip_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_kharej1_5iran() break else: print("\033[91mPlease select a valid option.\033[0m") # 1 iran 5 kharej client def update_gre6tap_ips( gre6_path, new_local_ip=None, new_remote_ip=None, new_private_ip=None ): try: with open(gre6_path, "r") as f: content = f.read() if new_local_ip: content = re.sub(r"local (\S+)", f"local {new_local_ip}", content) if new_remote_ip: content = re.sub(r"remote (\S+)", f"remote {new_remote_ip}", content) if new_private_ip: content = re.sub( r"ip -6 addr add \S+/64 dev azumig6?", f"ip -6 addr add {new_private_ip}/64 dev azumig6", content, ) with open(gre6_path, "w") as f: f.write(content) except FileNotFoundError: print(f"\033[91mFile {gre6_path} doesn't exist\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def wireguardafter_gre6tapnsec_iranconfig_1(): wireguard_config_path = "/etc/wireguard/wireserver1.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Server Config\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [1] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver1( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip1(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec1(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iranconfig_2(): wireguard_config_path = "/etc/wireguard/wireserver2.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Server Config\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [2] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver2( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip2(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec2(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi2(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iranconfig_3(): wireguard_config_path = "/etc/wireguard/wireserver3.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Server Config\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [3] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver3( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip3(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec3(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi3(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iranconfig_4(): wireguard_config_path = "/etc/wireguard/wireserver4.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Server Config\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [4] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver4( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip4(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secrett Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec4(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi4(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_iranconfig_5(): wireguard_config_path = "/etc/wireguard/wireserver5.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m IRAN Server Config\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is IRAN Server \033[97mConfig [5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print( "4.\033[93m Change \033[92mKharej Client [5] IP \033[96m(Endpoint IP)\033[0m" ) print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tapserver5( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_ip5(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec5(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip_multi5(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharej_client1(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre61.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Client\033[92m [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[1]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharej_client2(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre62.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Client\033[92m [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[2]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharej_client3(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre63.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Client\033[92m [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[3]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharej_client4(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre64.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Client\033[92m [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[4]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def wireguardafter_gre6tapnsec_kharej_client5(): wireguard_config_path = "/etc/wireguard/wireclient.conf" gre6_path = "/etc/gre65.sh" new_gre6_private_ip = None address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig(wireguard_config_path) ) local_ip_gre6 = local_ip(gre6_path) remote_ip_gre6 = remote_ip(gre6_path) private_ip_gre6 = private_gre6tap(gre6_path) if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCould not retrieve the WireGuard configuration.\033[0m") return if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("Could not retrieve the GRE6TAP IP addresses from gre6 file.") return while True: os.system("clear") display_wireguard_config(address_no_subnet, listen_port, endpoint, allowed_ips) display_stuff_gre6tapn(local_ip_gre6, remote_ip_gre6, private_ip_gre6) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireGuard & GRE6TAP IPSEC\033[97m Kharej Client\033[92m [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print(" \033[93mThis is Kharej Client \033[97m[5]\033[0m") print("1. \033[93mChange \033[97mWireGuard Private IP Address\033[0m") print("2. \033[93mChange \033[97mGRE6TAP\033[93m Private IP Address\033[0m") print("3. \033[93mChange \033[92mTunnel Port\033[0m") print("4.\033[93m Change \033[92mIRAN Server IP \033[96m(Endpoint IP)\033[0m") print("5.\033[94m Change IPsec Secret Key\033[0m") print("6. \033[92mSave and Exit\033[0m") print("0. Back to the previous menu") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice: ") if choice == "1": new_ip = input("\033[93mEnter New WireGuard Private IP Address : \033[0m") new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip local_ip_gre6 = new_ip remote_ip_gre6 = wtb_opposite_ip_wireguard(new_ip) allowed_ips = ( f"{remote_ip_gre6}/128" if ":" in new_ip else f"{remote_ip_gre6}/32" ) update_gre6tap_ips( gre6_path, new_local_ip=new_ip, new_remote_ip=remote_ip_gre6 ) update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(remote_ip_gre6) else: print("\033[91mInvalid IP Address!\033[0m") elif choice == "2": new_gre6_private_ip = input( "\033[93mEnter New GRE6TAP Private IP Address : \033[0m" ) if new_gre6_private_ip: private_ip_gre6 = new_gre6_private_ip update_gre6tap_ips(gre6_path, new_private_ip=private_ip_gre6) update_ipsec_conf_wireguard_gre6tap( "/etc/ipsec1.conf", new_gre6_private_ip ) else: print("\033[91mInvalid GRE6TAP Private IP Address!\033[0m") elif choice == "3": listen_port, endpoint = update_tunnel_port(listen_port, endpoint) update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, listen_port, listen_port ) elif choice == "4": endpoint = update_endpoint_ir_server(endpoint) elif choice == "5": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "Endpoint": endpoint, "AllowedIPs": allowed_ips, } save_wireguardconfigsec_client(wireguard_config_path, new_config) save_stuff_gretap65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) if new_gre6_private_ip: update_ipsec_ip(new_gre6_private_ip) break elif choice == "0": wireguard_gre6tapsec_noconjuction_1iran_5kharej() break else: print("\033[91mPlease select a valid option.\033[0m") def gre6tapwireguardeditserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Native + Wireguard Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tap_wireguard_nosec_edit_local() break elif choice == "2": gre6tap_wireguard_sec_edit_local() break elif choice == "3": clear() wireguard_edit_server() break else: print("Invalid choice.") def gre6tap_wireguard_nosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGre6tap[Native] + Wireguard \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print( "1. \033[92mGre6tap[native] + Wireguard - [1]Kharej Server [5]IRAN Clients\033[0m" ) print( "2. \033[93mGre6tap[native] + Wireguard - [1]IRAN Server [5]Kharej Clients\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_gre6tap_noconjuction_kharej1_5iran() break elif server_type == "2": wireguardedit_gre6tap_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") gre6tapwireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardedit_gre6tap_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapn_kharej_client1() break elif server_type == "2": wireguard_gre6tapn_kharej_client2() break elif server_type == "3": wireguard_gre6tapn_kharej_client3() break elif server_type == "4": wireguard_gre6tapn_kharej_client4() break elif server_type == "5": wireguard_gre6tapn_kharej_client5() break elif server_type == "6": wireguard_gre6tapn_iran_server() break elif server_type == "0": os.system("clear") gre6tap_wireguard_nosec_edit_local() break else: print("Invalid choice.") def wireguard_gre6tapn_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapn_iranconfig_1() break elif server_type == "2": wireguard_gre6tapn_iranconfig_2() break elif server_type == "3": wireguard_gre6tapn_iranconfig_3() break elif server_type == "4": wireguard_gre6tapn_iranconfig_4() break elif server_type == "5": wireguard_gre6tapn_iranconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Invalid choice.") def wireguardedit_gre6tap_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapn_iran_client1() break elif server_type == "2": wireguard_gre6tapn_iran_client2() break elif server_type == "3": wireguard_gre6tapn_iran_client3() break elif server_type == "4": wireguard_gre6tapn_iran_client4() break elif server_type == "5": wireguard_gre6tapn_iran_client5() break elif server_type == "6": wireguard_gre6tapn_kharej_server() break elif server_type == "0": os.system("clear") gre6tap_wireguard_nosec_edit_local() break else: print("Invalid choice.") def wireguard_gre6tapn_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapn_kharejconfig_1() break elif server_type == "2": wireguard_gre6tapn_kharejconfig_2() break elif server_type == "3": wireguard_gre6tapn_kharejconfig_3() break elif server_type == "4": wireguard_gre6tapn_kharejconfig_4() break elif server_type == "5": wireguard_gre6tapn_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Invalid choice.") ### def display_stuff_gre6tapn_wire_iran1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej [1] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej [2] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej [3] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej [4] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej [5] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran_client1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [1] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran_client2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [2] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran_client3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [3] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran_client4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [4] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_iran_client5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [5] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [1] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [2] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [3] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [4] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [5] IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej_server1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN [1] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej_server2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN [2] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej_server3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN [3] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej_server4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN [4] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_wire_kharej_server5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN [5] IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") # az inja def update_pingfile_sit(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip_sitwire(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def delete_ufw_rules(ip, port=None): counterpart_ip = wtb_opposite_ip_sitwire(ip) try: if port: subprocess.run( [ "sudo", "ufw", "delete", "allow", "from", ip, "to", "any", "port", port, ], check=False, ) subprocess.run( [ "sudo", "ufw", "delete", "allow", "from", counterpart_ip, "to", "any", "port", port, ], check=False, ) else: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules(ip, port=None): counterpart_ip = wtb_opposite_ip_sitwire(ip) try: if port: subprocess.run( ["sudo", "ufw", "allow", "from", ip, "to", "any", "port", port], check=True, ) subprocess.run( [ "sudo", "ufw", "allow", "from", counterpart_ip, "to", "any", "port", port, ], check=True, ) else: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_checkmark(message): print("\u2714 " + message) def private_native(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumi?", content) if match: return match.group(1) else: print("\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_native_ipsgre61(): private_ip_private = private_native("/etc/private1.sh") private_ip_gre6 = private_gre61("/etc/gre61.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def get_current_native_ipsgre62(): private_ip_private = private_native("/etc/private2.sh") private_ip_gre6 = private_gre61("/etc/gre62.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def get_current_native_ipsgre63(): private_ip_private = private_native("/etc/private3.sh") private_ip_gre6 = private_gre61("/etc/gre63.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def get_current_native_ipsgre64(): private_ip_private = private_native("/etc/private4.sh") private_ip_gre6 = private_gre61("/etc/gre64.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def get_current_native_ipsgre65(): private_ip_private = private_native("/etc/private5.sh") private_ip_gre6 = private_gre61("/etc/gre65.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def wtb_opposite_ip(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def update_ipfile_gre6_wire1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire1("/etc/gre61.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire2("/etc/gre62.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire3("/etc/gre63.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire4("/etc/gre64.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_gre6_wire5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6_wire5("/etc/gre65.sh", new_ip, update_type="gre6_local") update_ipfile_gre6_wire5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre61(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgre61() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_gre6_wire1("/etc/gre61.sh", private_ip, update_type="private") update_ipfile_gre6_wire1("/etc/gre61.sh", local_ip, update_type="local") update_ipfile_gre6_wire1("/etc/gre61.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_gre6_wire1( "/etc/private1.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_gre6_wire1( "/etc/private1.sh", remote_ip, update_type="remote" ) interface = "azumig61" if is_gre6 else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre62(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgre62() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_gre6_wire2("/etc/gre62.sh", private_ip, update_type="private") update_ipfile_gre6_wire2("/etc/gre62.sh", local_ip, update_type="local") update_ipfile_gre6_wire2("/etc/gre62.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_gre6_wire2( "/etc/private2.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_gre6_wire2( "/etc/private2.sh", remote_ip, update_type="remote" ) interface = "azumig62" if is_gre6 else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre63(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgre63() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_gre6_wire3("/etc/gre63.sh", private_ip, update_type="private") update_ipfile_gre6_wire3("/etc/gre63.sh", local_ip, update_type="local") update_ipfile_gre6_wire3("/etc/gre63.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_gre6_wire3( "/etc/private3.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_gre6_wire3( "/etc/private3.sh", remote_ip, update_type="remote" ) interface = "azumig63" if is_gre6 else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre64(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgre64() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_gre6_wire4("/etc/gre64.sh", private_ip, update_type="private") update_ipfile_gre6_wire4("/etc/gre64.sh", local_ip, update_type="local") update_ipfile_gre6_wire4("/etc/gre64.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_gre6_wire4( "/etc/private4.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_gre6_wire4( "/etc/private4.sh", remote_ip, update_type="remote" ) interface = "azumig64" if is_gre6 else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre65(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_native_ipsgre65() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_gre6_wire5("/etc/gre65.sh", private_ip, update_type="private") update_ipfile_gre6_wire5("/etc/gre65.sh", local_ip, update_type="local") update_ipfile_gre6_wire5("/etc/gre65.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_gre6_wire5( "/etc/private5.sh", private_ip, update_type="private" ) update_ipfile_gre6_wire5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_gre6_wire5( "/etc/private5.sh", remote_ip, update_type="remote" ) interface = "azumig65" if is_gre6 else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private_gre61(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumig6?", content) if match: return match.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def wtb_opposite_ip_wireguard(ip): return wtb_opposite_ip_sitwire(ip) def load_wireguardconfig_sitwire(file_path): try: with open(file_path, "r") as file: content = file.read() address_match = re.search(r"Address = ([^\s]+)", content) listen_port_match = re.search(r"ListenPort = (\d+)", content) endpoint_match = re.search(r"Endpoint = ([^\s]+):\d+", content) allowed_ips_match = re.search(r"AllowedIPs = ([^\s]+)", content) address = address_match.group(1) if address_match else "N/A" listen_port = listen_port_match.group(1) if listen_port_match else "N/A" endpoint = endpoint_match.group(1) if endpoint_match else "N/A" allowed_ips = allowed_ips_match.group(1) if allowed_ips_match else "N/A" return address, address.split("/")[0], listen_port, endpoint, allowed_ips except FileNotFoundError: print("\033[91mWireguard configuration file not found.\033[0m") return None, None, None, None, None except Exception as e: print(f"\033[91mAn error occurred: {e}\033[0m") return None, None, None, None, None def save_wireguardconfig_sitwire1sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_1.service", ] wg_quick_interface = "/etc/wireguard/wireserver1.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire2sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_2.service", ] wg_quick_interface = "/etc/wireguard/wireserver2.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire3sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_3.service", ] wg_quick_interface = "/etc/wireguard/wireserver3.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire4sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_4.service", ] wg_quick_interface = "/etc/wireguard/wireserver4.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire5sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_5.service", ] wg_quick_interface = "/etc/wireguard/wireserver5.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwiresec_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping.service", ] wg_quick_interface = "/etc/wireguard/wireclient.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def update_ufw_ruleswireguard(old_ip, new_ip, old_port=None, new_port=None): if old_port: delete_ufw_rules(old_ip, old_port) delete_ufw_rules(wtb_opposite_ip_wireguard(old_ip), old_port) add_ufw_rules(new_ip, new_port) add_ufw_rules(wtb_opposite_ip_wireguard(new_ip), new_port) def update_ping_script_opposite_ip_wirenosec_client(new_opposite_ip): script_path = "/etc/ping_wireguard.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec1(new_opposite_ip): script_path = "/etc/ping_wireguard_1.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec2(new_opposite_ip): script_path = "/etc/ping_wireguard_2.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec3(new_opposite_ip): script_path = "/etc/ping_wireguard_3.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec4(new_opposite_ip): script_path = "/etc/ping_wireguard_4.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec5(new_opposite_ip): script_path = "/etc/ping_wireguard_5.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec_client(new_opposite_ip): script_path = "/etc/ping_wireguard.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint, allowed_ips ): lines = [ f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mTitle: Wireguard Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mAddress: \033[97m{address_no_subnet}\033[0m", f"\033[92mListenPort: \033[97m{listen_port}\033[0m", f"\033[92mEndpoint: \033[97m{endpoint}\033[0m", f"\033[92mAllowedIPs: \033[97m{allowed_ips}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def wireguard_gre6tapn_iranconfig_1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_iranconfig_2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_iranconfig_3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_iranconfig_4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_iranconfig_5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharej_client1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharej_client2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharej_client3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharej_client4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharej_client5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") # 1 kharej server 5 iran client def wireguard_gre6tapn_kharejconfig_1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharejconfig_2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharejconfig_3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharejconfig_4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_kharejconfig_5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_iran_client1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_iran_client2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_iran_client3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_iran_client4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapn_iran_client5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_gre6tap_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") # ipsec def gre6tap_wireguard_sec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[Native] + Wireguard + IPSEC \033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print( "1. \033[92mGre6tap[native] + Wireguard - [1]Kharej Server [5]IRAN Clients\033[0m" ) print( "2. \033[93mGre6tap[native] + Wireguard - [1]IRAN Server [5]Kharej Clients\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break elif server_type == "2": wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") gre6tapwireguardeditserver_mnu() break else: print("Invalid choice.") def wireguardedit_gre6tapsec_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapnsec_kharej_client1() break elif server_type == "2": wireguard_gre6tapnsec_kharej_client2() break elif server_type == "3": wireguard_gre6tapnsec_kharej_client3() break elif server_type == "4": wireguard_gre6tapnsec_kharej_client4() break elif server_type == "5": wireguard_gre6tapnsec_kharej_client5() break elif server_type == "6": wireguard_gre6tapnsec_iran_server() break elif server_type == "0": os.system("clear") gre6tap_wireguard_sec_edit_local() break else: print("Invalid choice.") def wireguard_gre6tapnsec_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapnsec_iranconfig_1() break elif server_type == "2": wireguard_gre6tapnsec_iranconfig_2() break elif server_type == "3": wireguard_gre6tapnsec_iranconfig_3() break elif server_type == "4": wireguard_gre6tapnsec_iranconfig_4() break elif server_type == "5": wireguard_gre6tapnsec_iranconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Invalid choice.") def wireguardedit_gre6tapsec_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapnsec_iran_client1() break elif server_type == "2": wireguard_gre6tapnsec_iran_client2() break elif server_type == "3": wireguard_gre6tapnsec_iran_client3() break elif server_type == "4": wireguard_gre6tapnsec_iran_client4() break elif server_type == "5": wireguard_gre6tapnsec_iran_client5() break elif server_type == "6": wireguard_gre6tapnsec_kharej_server() break elif server_type == "0": os.system("clear") gre6tap_wireguard_sec_edit_local() break else: print("Invalid choice.") def wireguard_gre6tapnsec_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap[native] + Wireguard + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_gre6tapnsec_kharejconfig_1() break elif server_type == "2": wireguard_gre6tapnsec_kharejconfig_2() break elif server_type == "3": wireguard_gre6tapnsec_kharejconfig_3() break elif server_type == "4": wireguard_gre6tapnsec_kharejconfig_4() break elif server_type == "5": wireguard_gre6tapnsec_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Invalid choice.") # can be removed# def update_ipsec_conf_wireguard_server1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_46sec(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_obj = ipaddress.ip_address(new_private_ip) if isinstance(ip_obj, ipaddress.IPv6Address): ip_parts = new_private_ip.split(":") subnet_suffix = "/64" else: ip_parts = new_private_ip.split(".") subnet_suffix = "/32" ip_parts[-1] = "1" if ip_parts[-1].endswith("2") else "2" counterpart_ip = ( ":".join(ip_parts) if isinstance(ip_obj, ipaddress.IPv6Address) else ".".join(ip_parts) ) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet_suffix}", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet_suffix}", new_content, ) with open(name, "w") as f: f.write(new_content) print("\033[92mIPsec configuration updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def update_ipsecsecret_wire(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) display_checkmark("\033[92mIPsec secret key updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def ipsecsecret_key_wire(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mNo IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") return None def display_ipsecsecret_wire(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") # can be removed# def wireguard_gre6tapnsec_kharejconfig_1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharejconfig_2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) update_ipsec_ip_multi2(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharejconfig_3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) update_ipsec_ip_multi3(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharejconfig_4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) update_ipsec_ip_multi4(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharejconfig_5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej_server5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) update_ipsec_ip_multi5(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iran_client5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran_client5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_kharej1_5iran() break else: print("Please select a valid option.") # I iran 5 kharej client def wireguard_gre6tapnsec_iranconfig_1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iranconfig_2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) update_ipsec_ip_multi2(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iranconfig_3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) update_ipsec_ip_multi3(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iranconfig_4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) update_ipsec_ip_multi4(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_iranconfig_5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_iran5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m IRAN Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) update_ipsec_ip_multi5(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharej_client1(): local_ip_private = local_ip("/etc/gre61.sh") remote_ip_private = remote_ip("/etc/gre61.sh") private_ip_private = private_gre61("/etc/gre61.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharej_client2(): local_ip_private = local_ip("/etc/gre62.sh") remote_ip_private = remote_ip("/etc/gre62.sh") private_ip_private = private_gre61("/etc/gre62.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharej_client3(): local_ip_private = local_ip("/etc/gre63.sh") remote_ip_private = remote_ip("/etc/gre63.sh") private_ip_private = private_gre61("/etc/gre63.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharej_client4(): local_ip_private = local_ip("/etc/gre64.sh") remote_ip_private = remote_ip("/etc/gre64.sh") private_ip_private = private_gre61("/etc/gre64.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguard_gre6tapnsec_kharej_client5(): local_ip_private = local_ip("/etc/gre65.sh") remote_ip_private = remote_ip("/etc/gre65.sh") private_ip_private = private_gre61("/etc/gre65.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_gre6tapn_wire_kharej5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGre6tap[Native] + Wireguard\033[93m Kharej Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6.\033[94m Change IPsec Secret Key\033[0m") print("7. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "7": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=True ) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_gre6tapsec_noconjuction_1iran_5kharej() break else: print("Please select a valid option.") def wireguardsiteditserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardeditserver_nosec_sit_mnu() break elif server_type == "2": wireguardeditserver_sec_sit_mnu() break elif server_type == "0": os.system("clear") wireguard_edit_server() break else: print("Invalid choice.") def wireguardeditserver_nosec_sit_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard + SIT - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard + SIT - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_noconjuction_sit_kharej1_5iran() break elif server_type == "2": wireguardedit_noconjuction_sit_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguardsiteditserver_mnu() break else: print("Invalid choice.") def wireguardedit_noconjuction_sit_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_sit_iran_client1() break elif server_type == "2": wireguardudp_sit_iran_client2() break elif server_type == "3": wireguardudp_sit_iran_client3() break elif server_type == "4": wireguardudp_sit_iran_client4() break elif server_type == "5": wireguardudp_sit_iran_client5() break elif server_type == "6": wireguardudpedit_sit_kharej_server() break elif server_type == "0": os.system("clear") wireguardeditserver_nosec_sit_mnu() break else: print("Invalid choice.") def wireguardudpedit_sit_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_sit_kharejconfig_1() break elif server_type == "2": wireguardedit_sit_kharejconfig_2() break elif server_type == "3": wireguardedit_sit_kharejconfig_3() break elif server_type == "4": wireguardedit_sit_kharejconfig_4() break elif server_type == "5": wireguardedit_sit_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Invalid choice.") def wireguardedit_noconjuction_sit_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_sit_kharej_client1() break elif server_type == "2": wireguardudp_sit_kharej_client2() break elif server_type == "3": wireguardudp_sit_kharej_client3() break elif server_type == "4": wireguardudp_sit_kharej_client4() break elif server_type == "5": wireguardudp_sit_kharej_client5() break elif server_type == "6": wireguardudpedit_sit_iran_server() break elif server_type == "0": os.system("clear") wireguardeditserver_nosec_sit_mnu() break else: print("Invalid choice.") def wireguardudpedit_sit_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_sit_iranconfig_1() break elif server_type == "2": wireguardedit_sit_iranconfig_2() break elif server_type == "3": wireguardedit_sit_iranconfig_3() break elif server_type == "4": wireguardedit_sit_iranconfig_4() break elif server_type == "5": wireguardedit_sit_iranconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Invalid choice.") def wtb_opposite_ip_sitwire(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def delete_ufw_rules(ip, port=None): counterpart_ip = wtb_opposite_ip_sitwire(ip) try: if port: subprocess.run( [ "sudo", "ufw", "delete", "allow", "from", ip, "to", "any", "port", port, ], check=False, ) subprocess.run( [ "sudo", "ufw", "delete", "allow", "from", counterpart_ip, "to", "any", "port", port, ], check=False, ) else: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules(ip, port=None): counterpart_ip = wtb_opposite_ip_sitwire(ip) try: if port: subprocess.run( ["sudo", "ufw", "allow", "from", ip, "to", "any", "port", port], check=True, ) subprocess.run( [ "sudo", "ufw", "allow", "from", counterpart_ip, "to", "any", "port", port, ], check=True, ) else: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_checkmark(message): print("\u2714 " + message) def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private_ip1(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi?", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_pingfile_sit(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi1", f"ip -6 addr add {new_ip}/64 dev azumi1", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi1", f"ip -6 route add {counterpart_ip}/64 dev azumi1", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi2", f"ip -6 addr add {new_ip}/64 dev azumi2", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi2", f"ip -6 route add {counterpart_ip}/64 dev azumi2", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi3", f"ip -6 addr add {new_ip}/64 dev azumi3", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi3", f"ip -6 route add {counterpart_ip}/64 dev azumi3", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi4", f"ip -6 addr add {new_ip}/64 dev azumi4", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi4", f"ip -6 route add {counterpart_ip}/64 dev azumi4", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi5", f"ip -6 addr add {new_ip}/64 dev azumi5", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi5", f"ip -6 route add {counterpart_ip}/64 dev azumi5", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit1(private_ip, local_ip, remote_ip): current_ips = {"private": private_ip1("/etc/private1.sh")} current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_sit1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_sit1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_sit1("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumi1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v61"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit2(private_ip, local_ip, remote_ip): current_ips = {"private": private_ip1("/etc/private2.sh")} current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_sit2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_sit2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_sit2("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumi2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v62"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit3(private_ip, local_ip, remote_ip): current_ips = {"private": private_ip1("/etc/private3.sh")} current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_sit3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_sit3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_sit3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumi3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v63"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit4(private_ip, local_ip, remote_ip): current_ips = {"private": private_ip1("/etc/private4.sh")} current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_sit4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_sit4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_sit4("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumi4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v64"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit5(private_ip, local_ip, remote_ip): current_ips = {"private": private_ip1("/etc/private5.sh")} current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip_sitwire(private_ip) try: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_sit5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_sit5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_sit5("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumi5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v65"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip_wireguard(ip): return wtb_opposite_ip_sitwire(ip) def load_wireguardconfig_sitwire(file_path): try: with open(file_path, "r") as file: content = file.read() address_match = re.search(r"Address = ([^\s]+)", content) listen_port_match = re.search(r"ListenPort = (\d+)", content) endpoint_match = re.search(r"Endpoint = ([^\s]+):\d+", content) allowed_ips_match = re.search(r"AllowedIPs = ([^\s]+)", content) address = address_match.group(1) if address_match else "N/A" listen_port = listen_port_match.group(1) if listen_port_match else "N/A" endpoint = endpoint_match.group(1) if endpoint_match else "N/A" allowed_ips = allowed_ips_match.group(1) if allowed_ips_match else "N/A" return address, address.split("/")[0], listen_port, endpoint, allowed_ips except FileNotFoundError: print("\033[91mWireguard configuration file not found.\033[0m") return None, None, None, None, None except Exception as e: print(f"\033[91mAn error occurred: {e}\033[0m") return None, None, None, None, None def save_wireguardconfig_sitwire1(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_1.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver1.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver1.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def save_wireguardconfig_sitwire2(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_2.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver2.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver2.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def save_wireguardconfig_sitwire3(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_3.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver3.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver3.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def save_wireguardconfig_sitwire4(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_4.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver4.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver4.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def save_wireguardconfig_sitwire5(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping_5.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireserver5.conf"], check=True ) subprocess.run( ["wg-quick", "up", "/etc/wireguard/wireserver5.conf"], check=True ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def save_wireguardconfig_sitwire_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) service_name = "wireguardping.service" service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode != 0: print(f"\033[91mService {service_name} doesn't exist or is inactive\033[0m") subprocess.run( ["wg-quick", "down", "/etc/wireguard/wireclient.conf"], check=True ) subprocess.run(["wg-quick", "up", "/etc/wireguard/wireclient.conf"], check=True) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in restating services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving da config: {e}\033[0m") def update_ufw_ruleswireguard(old_ip, new_ip, old_port=None, new_port=None): if old_port: delete_ufw_rules(old_ip, old_port) delete_ufw_rules(wtb_opposite_ip_wireguard(old_ip), old_port) add_ufw_rules(new_ip, new_port) add_ufw_rules(wtb_opposite_ip_wireguard(new_ip), new_port) def update_ping_script_opposite_ip_wirenosec_client(new_opposite_ip): script_path = "/etc/ping_wireguard.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec1(new_opposite_ip): script_path = "/etc/ping_wireguard_1.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec2(new_opposite_ip): script_path = "/etc/ping_wireguard_2.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec3(new_opposite_ip): script_path = "/etc/ping_wireguard_3.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec4(new_opposite_ip): script_path = "/etc/ping_wireguard_4.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def update_ping_script_opposite_ip_wirenosec5(new_opposite_ip): script_path = "/etc/ping_wireguard_5.sh" try: with open(script_path, "r") as f: script_content = f.read() updated_script_content = re.sub( r'ip_address="[^"]+"', f'ip_address="{new_opposite_ip}"', script_content ) with open(script_path, "w") as f: f.write(updated_script_content) display_checkmark( "\033[92mPing script updated with new opposite IP address!\033[0m" ) except FileNotFoundError: print(f"\033[91mPing script {script_path} not found.\033[0m") except Exception as e: print(f"\033[91mError updating ping script: {e}\033[0m") def display_stuff_sitwire_privateiran1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[1]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[2]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[3]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[4]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[5]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[1]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[2]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[3]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[4]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[5]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint, allowed_ips ): lines = [ f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mTitle: Wireguard Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mAddress: \033[97m{address_no_subnet}\033[0m", f"\033[92mListenPort: \033[97m{listen_port}\033[0m", f"\033[92mEndpoint: \033[97m{endpoint}\033[0m", f"\033[92mAllowedIPs: \033[97m{allowed_ips}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def wireguardedit_sit_iranconfig_1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sit_iranconfig_2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sit_iranconfig_3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sit_iranconfig_4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sit_iranconfig_5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sit_kharej_client1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sit_kharej_client2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sit_kharej_client3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sit_kharej_client4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sit_kharej_client5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def display_stuff_sitwire_privateiran_client1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[1] Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran_client2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[2] Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran_client3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[3] Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran_client4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[4] Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privateiran_client5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[5] Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej_server1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[1]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej_server2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[2]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej_server3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[3]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej_server4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[4]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_sitwire_privatekharej_server5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[5]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def wireguardedit_sit_kharejconfig_1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sit_kharejconfig_2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sit_kharejconfig_3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sit_kharejconfig_4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sit_kharejconfig_5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sit_iran_client1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sit_iran_client2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sit_iran_client3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sit_iran_client4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sit_iran_client5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7. \033[92mSave All Stuff\033[0m") print("0. \033[97mback to the related menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "7": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire_client(config_path, new_config) break elif choice == "0": clear() wireguardedit_noconjuction_sit_kharej1_5iran() break else: print("Please select a valid option.") # ipsec def wireguardeditserver_sec_sit_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[93m Edit Menu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print( "1. \033[92mWireguard + SIT + IPSEC - [1]Kharej Server [5]IRAN Clients\033[0m" ) print( "2. \033[93mWireguard + SIT + IPSEC - [1]IRAN Server [5]Kharej Clients\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_noconjuction_sitsec_kharej1_5iran() break elif server_type == "2": wireguardedit_noconjuction_sitsec_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguardsiteditserver_mnu() break else: print("Invalid choice.") def wireguardedit_noconjuction_sitsec_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_sitsec_iran_client1() break elif server_type == "2": wireguardudp_sitsec_iran_client2() break elif server_type == "3": wireguardudp_sitsec_iran_client3() break elif server_type == "4": wireguardudp_sitsec_iran_client4() break elif server_type == "5": wireguardudp_sitsec_iran_client5() break elif server_type == "6": wireguardudpedit_sitsec_kharej_server() break elif server_type == "0": os.system("clear") wireguardeditserver_sec_sit_mnu() break else: print("Invalid choice.") def wireguardudpedit_sitsec_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Server Config [1] \033[0m") print("2. \033[92mKharej Server Config [2]\033[0m") print("3. \033[93mKharej Server Config [3]\033[0m") print("4. \033[92mKharej Server Config [4]\033[0m") print("5. \033[92mKharej Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_sitsec_kharejconfig_1() break elif server_type == "2": wireguardedit_sitsec_kharejconfig_2() break elif server_type == "3": wireguardedit_sitsec_kharejconfig_3() break elif server_type == "4": wireguardedit_sitsec_kharejconfig_4() break elif server_type == "5": wireguardedit_sitsec_kharejconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Invalid choice.") def wireguardedit_noconjuction_sitsec_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardudp_sitsec_kharej_client1() break elif server_type == "2": wireguardudp_sitsec_kharej_client2() break elif server_type == "3": wireguardudp_sitsec_kharej_client3() break elif server_type == "4": wireguardudp_sitsec_kharej_client4() break elif server_type == "5": wireguardudp_sitsec_kharej_client5() break elif server_type == "6": wireguardudpedit_sitsec_iran_server() break elif server_type == "0": os.system("clear") wireguardeditserver_sec_sit_mnu() break else: print("Invalid choice.") def wireguardudpedit_sitsec_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93m Edit Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Server Config [1] \033[0m") print("2. \033[92mIRAN Server Config [2]\033[0m") print("3. \033[93mIRAN Server Config [3]\033[0m") print("4. \033[92mIRAN Server Config [4]\033[0m") print("5. \033[92mIRAN Server Config [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardedit_sitsec_iranconfig_1() break elif server_type == "2": wireguardedit_sitsec_iranconfig_2() break elif server_type == "3": wireguardedit_sitsec_iranconfig_3() break elif server_type == "4": wireguardedit_sitsec_iranconfig_4() break elif server_type == "5": wireguardedit_sitsec_iranconfig_5() break elif server_type == "0": os.system("clear") wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Invalid choice.") def update_ipsec_conf_wireguard_server1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_wireguard_server5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn wireguard_server5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn wireguard_server5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_type = ( "ipv6" if isinstance(ipaddress.ip_address(new_private_ip), ipaddress.IPv6Address) else "ipv4" ) if ip_type == "ipv6": subnet = "/64" else: subnet = "/32" ip_parts = ( new_private_ip.split(".") if ip_type == "ipv4" else new_private_ip.split(":") ) if new_private_ip.endswith(".2") or new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) if ip_type == "ipv4" else ":".join(ip_parts) new_section = [] for line in section: line = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet}", line ) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet}", line ) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn wireguard_server5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_wireguardconfig_sitwire1sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_1.service", ] wg_quick_interface = "/etc/wireguard/wireserver1.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire2sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_2.service", ] wg_quick_interface = "/etc/wireguard/wireserver2.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire3sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_3.service", ] wg_quick_interface = "/etc/wireguard/wireserver3.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire4sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_4.service", ] wg_quick_interface = "/etc/wireguard/wireserver4.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwire5sec(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping_5.service", ] wg_quick_interface = "/etc/wireguard/wireserver5.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def save_wireguardconfig_sitwiresec_client(file_path, new_config): try: with open(file_path, "r") as f: config = f.read() listen_port_pattern = r"ListenPort\s*=\s*\d+" endpoint_pattern = r"Endpoint\s*=\s*([^\s]+):\d+" address_pattern = r"Address\s*=\s*[^\s]+" allowed_ips_pattern = r"AllowedIPs\s*=\s*[^\s]+" new_config_content = re.sub( listen_port_pattern, f'ListenPort = {new_config["ListenPort"]}', config ) new_config_content = re.sub( address_pattern, f'Address = {new_config["Address"]}', new_config_content ) new_config_content = re.sub( allowed_ips_pattern, f'AllowedIPs = {new_config["AllowedIPs"]}', new_config_content, ) def replace_endpoint(match): endpoint_ip = new_config["EndpointIP"] return f'Endpoint = {endpoint_ip}:{new_config["ListenPort"]}' new_config_content = re.sub( endpoint_pattern, replace_endpoint, new_config_content ) with open(file_path, "w") as f: f.write(new_config_content) subprocess.run(["systemctl", "daemon-reload"], check=True) services_to_restart = [ "strong-azumi1", "wireguardping.service", ] wg_quick_interface = "/etc/wireguard/wireclient.conf" wg_quick_down = subprocess.run( ["wg-quick", "down", wg_quick_interface], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if wg_quick_down.returncode == 0: subprocess.run(["wg-quick", "up", wg_quick_interface], check=True) display_checkmark( f"\033[92mInterface {wg_quick_interface} brought down and up successfully!\033[0m" ) else: print( f"\033[93mFailed to bring down interface {wg_quick_interface}.\033[0m" ) for service_name in services_to_restart: service_status = subprocess.run( ["systemctl", "is-active", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if service_status.returncode == 0: subprocess.run(["systemctl", "restart", service_name], check=True) display_checkmark( f"\033[92mService {service_name} restarted successfully!\033[0m" ) else: print( f"\033[93mService {service_name} doesn't exist or is inactive.\033[0m" ) display_checkmark(f"\033[92mConfiguration updated successfully!\033[0m") except FileNotFoundError: print(f"\033[91mfile {file_path} not found.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror in managing services: {e}\033[0m") except Exception as e: print(f"\033[91merror in saving the config: {e}\033[0m") def update_ipsec_conf_wireguard_46sec(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_obj = ipaddress.ip_address(new_private_ip) if isinstance(ip_obj, ipaddress.IPv6Address): ip_parts = new_private_ip.split(":") subnet_suffix = "/64" else: ip_parts = new_private_ip.split(".") subnet_suffix = "/32" ip_parts[-1] = "1" if ip_parts[-1].endswith("2") else "2" counterpart_ip = ( ":".join(ip_parts) if isinstance(ip_obj, ipaddress.IPv6Address) else ".".join(ip_parts) ) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}{subnet_suffix}", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}{subnet_suffix}", new_content, ) with open(name, "w") as f: f.write(new_content) print("\033[92mIPsec configuration updated successfully!\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def wireguardedit_sitsec_iranconfig_1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sitsec_iranconfig_2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) update_ipsec_ip_multi2(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sitsec_iranconfig_3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) update_ipsec_ip_multi3(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sitsec_iranconfig_4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) update_ipsec_ip_multi4(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardedit_sitsec_iranconfig_5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) update_ipsec_ip_multi5(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sitsec_kharej_client1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sitsec_kharej_client2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sitsec_kharej_client3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sitsec_kharej_client4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") def wireguardudp_sitsec_kharej_client5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_1iran_5kharej() break else: print("Please select a valid option.") # 1 kharej server 5 iran client def wireguardedit_sitsec_kharejconfig_1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireserver1.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [1] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec1(opposite_ip) update_ipsec_conf_wireguard_server1("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire1sec(config_path, new_config) update_ipsec_ip_multi(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sitsec_kharejconfig_2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireserver2.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [2] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec2(opposite_ip) update_ipsec_conf_wireguard_server2("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire2sec(config_path, new_config) update_ipsec_ip_multi2(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sitsec_kharejconfig_3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireserver3.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [3] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec3(opposite_ip) update_ipsec_conf_wireguard_server3("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire3sec(config_path, new_config) update_ipsec_ip_multi3(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sitsec_kharejconfig_4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireserver4.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [4] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec4(opposite_ip) update_ipsec_conf_wireguard_server4("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire4sec(config_path, new_config) update_ipsec_ip_multi4(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardedit_sitsec_kharejconfig_5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireserver5.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privatekharej_server5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m Kharej Server \033[96mConfig [5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej Server\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN Client [5] \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec5(opposite_ip) update_ipsec_conf_wireguard_server5("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwire5sec(config_path, new_config) update_ipsec_ip_multi5(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sitsec_iran_client1(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client1( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sitsec_iran_client2(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client2( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sitsec_iran_client3(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client3( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sitsec_iran_client4(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client4( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def wireguardudp_sitsec_iran_client5(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") config_path = "/etc/wireguard/wireclient.conf" address_with_subnet, address_no_subnet, listen_port, endpoint, allowed_ips = ( load_wireguardconfig_sitwire(config_path) ) if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return if not address_with_subnet or not listen_port or not endpoint: print("\033[91mCouldn't retrieve the Wireguard configuration.\033[0m") return while True: os.system("clear") display_stuff_sitwire_privateiran_client5( local_ip_private, remote_ip_private, private_ip_private ) opposite_ip = wtb_opposite_ip_wireguard(private_ip_private) endpoint_display = f"{opposite_ip}:{listen_port}" display_wireguard_config_sitwire( address_no_subnet, listen_port, endpoint_display, allowed_ips ) secret_key = ipsecsecret_key_wire("/etc/ipsec.secrets") if secret_key: display_ipsecsecret_wire(secret_key) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT] + Wireguard\033[93m IRAN Client \033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN Client [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej Server \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[92mChange \033[97mWireGuard Private IP\033[92m Address\033[0m") print("5. \033[96mChange WireGuard Tunnel Port\033[0m") print("6. \033[93mChange WireGuard Endpoint IP\033[0m") print("7.\033[94m Change IPsec Secret Key\033[0m") print("8. \033[92mSave All Changes\033[0m") print("0. \033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter \033[92New Private IPv6 \033[93maddress \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) endpoint = f"{opposite_ip}:{listen_port}" else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN Client [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter\033[92m New WireGuard Private IP\033[93m Address : \033[0m" ) new_subnet = address_with_subnet.split("/")[-1] if new_ip: old_ip = address_no_subnet new_address = f"{new_ip}/{new_subnet}" address_with_subnet = new_address address_no_subnet = new_ip opposite_ip = wtb_opposite_ip_wireguard(new_ip) if ":" in new_ip: allowed_ips = f"{opposite_ip}/128" else: allowed_ips = f"{opposite_ip}/32" update_ufw_ruleswireguard(old_ip, new_ip, listen_port, listen_port) update_ping_script_opposite_ip_wirenosec_client(opposite_ip) update_ipsec_conf_wireguard_46sec("/etc/ipsec1.conf", new_ip) else: print("\033[91minvalid IP Address!\033[0m") elif choice == "5": new_listen_port = input( "\033[93mEnter New \033[92mTunnel\033[93m Port:\033[0m " ) if new_listen_port.isdigit(): old_port = listen_port listen_port = new_listen_port update_ufw_ruleswireguard( address_no_subnet, address_no_subnet, old_port, new_listen_port ) else: print("\033[91minvalid Port!\033[0m") elif choice == "7": new_secret = input( "\033[93mEnter\033[92m New IPsec Secret Key\033[93m:\033[0m " ) if new_secret: update_ipsecsecret_wire("/etc/ipsec.secrets", new_secret) else: print("\033[91mInvalid IPsec Secret Key!\033[0m") elif choice == "6": new_endpoint = input( "\033[93mEnter New \033[92mWireGuard Endpoint\033[93m Address:\033[0m " ) if new_endpoint: try: endpoint_ip, new_port = new_endpoint.rsplit(":", 1) if endpoint.startswith(endpoint_ip): endpoint = f"{endpoint_ip}:{new_port}" else: print( "\033[97mSince Endpoint IP doesn't match with the original one, only port will be updated\033[0m" ) except ValueError: print("\033[91minvalid Endpoint format\033[0m") else: print("\033[91minvalid Endpoint Address!\033[0m") elif choice == "8": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) new_config = { "Address": address_with_subnet, "ListenPort": listen_port, "EndpointIP": opposite_ip, "AllowedIPs": allowed_ips, } save_wireguardconfig_sitwiresec_client(config_path, new_config) update_ipsec_ip(address_no_subnet) break elif choice == "0": clear() wireguardedit_noconjuction_sitsec_kharej1_5iran() break else: print("Please select a valid option.") def update_ipsec_ip(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] for line in lines: if ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] modified = False for line in lines: if not modified and ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") modified = True else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi2(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 2: raise ValueError("The secrets file doesn't have at least 2 lines") new_lines = [] for index, line in enumerate(lines): if index == 1 and ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi3(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 3: raise ValueError("The secrets file doesn't have at least 3 lines") new_lines = [] for index, line in enumerate(lines): if index == 2: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi4(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 4: raise ValueError("The secrets file doesn't have at least 4 lines") new_lines = [] for index, line in enumerate(lines): if index == 3: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi5(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 5: raise ValueError("The secrets file doesn't have at least 5 lines") new_lines = [] for index, line in enumerate(lines): if index == 4: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def clear(): subprocess.run(["clear"]) ## edit menu close## def remote_extraction(file_path): with open(file_path, "r") as file: content = file.read() match_ipv4 = re.search( r"remote\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", content ) match_ipv6 = re.search(r"remote\s+([0-9a-fA-F:]+)", content) if match_ipv4: return match_ipv4.group(1) elif match_ipv6: return match_ipv6.group(1) return None def remote_extraction_sit(file_path): with open(file_path, "r") as file: content = file.read() match = re.search(r"remote\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", content) if match: return match.group(1) return None def remote_endpoint(file_path): with open(file_path, "r") as file: content = file.read() match = re.search(r"\[Peer\][\s\S]*?Endpoint\s*=\s*([\d\.]+)", content) if match: return match.group(1) return None def parse_wireguard_config(file_path): with open(file_path, "r") as file: content = file.read() endpoint = re.search(r"Endpoint\s*=\s*(\S+)", content) mtu = re.search(r"MTU\s*=\s*(\d+)", content) port = re.search(r"ListenPort\s*=\s*(\d+)", content) return { "endpoint": endpoint.group(1) if endpoint else None, "mtu": mtu.group(1) if mtu else None, "port": port.group(1) if port else None, } def interface_ex(interface): output = subprocess.run( ["ip", "a", "show", interface], capture_output=True, text=True ) return output.returncode == 0 def interface_check(interface): output = subprocess.run( ["ip", "a", "show", interface], capture_output=True, text=True ) if output.returncode == 0: if re.search(r"state (UP|UNKNOWN)", output.stdout): return "online" return "offline" def wireguard_status(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard Status Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭─────────────────────────────────────────────────╮\033[0m") print("\033[93mYou are viewing the status of your current tunnels:\033[0m") interfaces = [ "wireserver5", "azumig65", "wireserver4", "azumig64", "wireserver3", "azumig63", "wireserver2", "azumig62", "wireserver1", "azumig61", "wireclient", "azumi5", "azumi4", "azumi3", "azumi2", "azumi1", ] active_int = {} for interface in interfaces: if interface_ex(interface): status = interface_check(interface) if status == "online": active_int[interface] = True if not active_int: print(" No Interfaces available.") return config_pairs = [ ( "wireserver5", "azumig65", "/etc/gre65.sh", "/etc/wireguard/wireserver5.conf", "Server Config [5]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireserver4", "azumig64", "/etc/gre64.sh", "/etc/wireguard/wireserver4.conf", "Server Config [4]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireserver3", "azumig63", "/etc/gre63.sh", "/etc/wireguard/wireserver3.conf", "Server Config [3]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireserver2", "azumig62", "/etc/gre62.sh", "/etc/wireguard/wireserver2.conf", "Server Config [2]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireserver1", "azumig61", "/etc/gre61.sh", "/etc/wireguard/wireserver1.conf", "Server Config [1]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireclient", "azumig65", "/etc/gre65.sh", "/etc/wireguard/wireclient.conf", "Client [5]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireclient", "azumig64", "/etc/gre64.sh", "/etc/wireguard/wireclient.conf", "Client [4]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireclient", "azumig63", "/etc/gre63.sh", "/etc/wireguard/wireclient.conf", "Client [3]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireclient", "azumig62", "/etc/gre62.sh", "/etc/wireguard/wireclient.conf", "Client [2]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireclient", "azumig61", "/etc/gre61.sh", "/etc/wireguard/wireclient.conf", "Client [1]", "Native GRE6TAP + WireGuard", "WireGuard + GRE6TAP", ), ( "wireserver5", "azumi5", "/etc/private5.sh", "/etc/wireguard/wireserver5.conf", "Server Config [5]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireserver4", "azumi4", "/etc/private4.sh", "/etc/wireguard/wireserver4.conf", "Server Config [4]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireserver3", "azumi3", "/etc/private3.sh", "/etc/wireguard/wireserver3.conf", "Server Config [3]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireserver2", "azumi2", "/etc/private2.sh", "/etc/wireguard/wireserver2.conf", "Server Config [2]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireserver1", "azumi1", "/etc/private1.sh", "/etc/wireguard/wireserver1.conf", "Server Config [1]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireclient", "azumi5", "/etc/private5.sh", "/etc/wireguard/wireclient.conf", "Client [5]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireclient", "azumi4", "/etc/private4.sh", "/etc/wireguard/wireclient.conf", "Client [4]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireclient", "azumi3", "/etc/private3.sh", "/etc/wireguard/wireclient.conf", "Client [3]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireclient", "azumi2", "/etc/private2.sh", "/etc/wireguard/wireclient.conf", "Client [2]", "Sit + Wireguard", "Sit + Wireguard", ), ( "wireclient", "azumi1", "/etc/private1.sh", "/etc/wireguard/wireclient.conf", "Client [1]", "Sit + Wireguard", "Sit + Wireguard", ), ] displayed_servers = set() for ( int_a, int_b, gre_file, wg_file, config_label, tunnel_type_ipv6, tunnel_type_ipv4, ) in config_pairs: if active_int.get(int_a) and active_int.get(int_b): remote_ip = ( remote_extraction(gre_file) if "private" not in gre_file else remote_extraction_sit(gre_file) ) wg_config = parse_wireguard_config(wg_file) if remote_ip: if config_label not in displayed_servers: if ":" in remote_ip: # IPv6 print( "\033[93m─────────────────────────────────────────────────\033[0m" ) print(f" \033[93mThis is \033[92m{config_label}\033[0m") print( f" \033[97mTunnel Type: \033[92m{tunnel_type_ipv6}\033[0m" ) print( f" \033[93mRemote \033[92m[Client]\033[93m IP Address : \033[97m{remote_ip}\033[0m" ) else: # IPv4 print( "\033[93m─────────────────────────────────────────────────\033[0m" ) print(f" \033[93mThis is \033[92m{config_label}\033[0m") print( f" \033[97mTunnel Type: \033[92m{tunnel_type_ipv4}\033[0m" ) if wg_config["endpoint"]: print( f" \033[93mRemote \033[92m[Client]\033[93m IP Address : \033[97m{wg_config['endpoint'].split(':')[0]}\033[0m" ) print(f" \033[93mPort: \033[97m{wg_config['port']}\033[0m") print(f" \033[93mMTU: \033[97m{wg_config['mtu']}\033[0m") displayed_servers.add(config_label) additional_servers = [ ( "wireserver5", "Server Config [5]", "/etc/wireguard/wireserver5.conf", ), ( "wireserver4", "Server Config [4]", "/etc/wireguard/wireserver4.conf", ), ( "wireserver3", "Server Config [3]", "/etc/wireguard/wireserver3.conf", ), ( "wireserver2", "Server Config [2]", "/etc/wireguard/wireserver2.conf", ), ( "wireserver1", "Server Config [1]", "/etc/wireguard/wireserver1.conf", ), ("wireclient", "Client", "/etc/wireguard/wireclient.conf"), ] for interface, label, config_path in additional_servers: if active_int.get(interface) and label not in displayed_servers: remote_ip = remote_endpoint(config_path) wg_config = parse_wireguard_config(config_path) if remote_ip: print( "\033[93m─────────────────────────────────────────────────\033[0m" ) print(f" \033[93mThis is \033[92m{label}\033[0m") print(f" \033[97mTunnel Type: \033[92mWireGuard UDP\033[0m") print( f" \033[93mRemote \033[92mClient\033[93m IP Address \033[96m[{interface[-1]}]: \033[97m{remote_ip}\033[0m" ) print(f" \033[93mPort: \033[97m{wg_config['port']}\033[0m") print(f" \033[93mMTU: \033[97m{wg_config['mtu']}\033[0m") print( "\033[93m─────────────────────────────────────────────────\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") ##this can be removed ### def write_config(file_path, content): with open(file_path, "w") as file: file.write(content) def iran_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def iran_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def iran_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def iran_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def iran_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def display_checkmark(message): print("\u2714 " + message) def check_wireguard_installed(): try: subprocess.check_output(["dpkg", "-s", "wireguard"]) print("\033[92mWireGuard is already installed\033[0m") except subprocess.CalledProcessError: print("\033[93mWireGuard is not installed. \033[92mInstalling now..\033[0m") wire(["sudo", "apt-get", "install", "wireguard", "-y"]) animate("\033[92mWireGuard is installed\033[0m") def generate_keys(): private_key = ( subprocess.check_output("wg genkey", shell=True).strip().decode("utf-8") ) public_key = ( subprocess.check_output(f"echo {private_key} | wg pubkey", shell=True) .strip() .decode("utf-8") ) return private_key, public_key def keynconfig(keypath, content): with open(keypath, "w") as file: file.write(content) def display_notification(message): print("\u2728 " + message) def permissionz(): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def config_ipsecn1k(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::1/64\n") f.write(f" leftid=2002:8{i+0}1a::1\n") f.write(f" right=2002:8{i+0}1a::2\n") f.write(f" rightsubnet=2002:8{i+0}1a::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::2 2002:8{i+0}1a::1 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn1i(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::2/64\n") f.write(f" leftid=2002:8{i+0}1a::2\n") f.write(f" right=2002:8{i+0}1a::1\n") f.write(f" rightsubnet=2002:8{i+0}1a::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::1 2002:8{i+0}1a::2 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def restart_forced_strongazumi(): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL ) def iran_gre61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def iran_gre62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def iran_gre63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def iran_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def iran_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) ### this can be removed ^^^ #### # this is the question for 1 iran 5 kharej def irangretap_q_wire(server_ips, client_ips): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mGRE6Tap IRAN Config !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: num_servers = len(client_ips) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, num_servers) num_servers = len(client_ips) for i in range(1, num_servers + 1): menu_name = "gre6tap2_iran{}_wireguard".format(i) globals()[menu_name](server_ips[i - 1], client_ips[i - 1]) restart_forced_strongazumi() # this is the question for 1 kharej 5 iran def kharejgretap_q_wire(server_ips, client_ips): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mGRE6Tap Kharej Config !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: num_servers = len(client_ips) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) num_servers = len(client_ips) for i in range(num_servers): menu_name = "gre6tap2_kharej{}_wireguard".format(i + 1) globals()[menu_name](server_ips[i], client_ips[i]) restart_forced_strongazumi() def ipaddr(options, iptype): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(f"\033[93mChoose an IPv6 address for {iptype}:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") for i, option in enumerate(options, 1): print(f"{i}) {option}") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = int(input("\033[93mPlease choose: \033[0m")) if choice == len(options): print( "\033[93m─────────────────────────────────────────────────────────\033[0m" ) return input(f"\033[93mEnter the Manual IPv6 address for {iptype}: \033[0m") return options[choice - 1] def animate(message): for char in message: print(char, end="", flush=True) time.sleep(0.05) print() def anime(): animation = [ "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[======]", "[===== ]", "[==== ]", "[=== ]", "[== ]", "[= ]", ] for i in range(20): time.sleep(0.1) sys.stdout.write(f"\r{animation[i % len(animation)]}") sys.stdout.flush() sys.stdout.write("\r") sys.stdout.flush() def wire(command): process = subprocess.Popen( command, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE ) while process.poll() is None: anime() _, stderr = process.communicate() if process.returncode != 0: print(f"\033[91merror: {stderr.decode()}\033[0m") def hide(command): process = subprocess.Popen( command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE ) while process.poll() is None: anime() _, stderr = process.communicate() if process.returncode != 0: print(f"\033[91merror: {stderr.decode()}\033[0m") def ipaddrv6(ip_options, config_name, ip_type="ipv6"): if ip_type == "ipv6": return ip_options[0] else: return ip_options[1] def servernclient_ipv6(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(f"\033[93mConfiguring Server & Client {client_num}\033[0m") server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mKharej\033[93m Server\033[96m Config\033[97m {client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mIRAN\033[93m Client\033[96m {client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" print("\033[93m───────────────────────────────────────\033[0m") print( f"\033[93mSelect \033[92mKharej \033[93mServer \033[97mConfig\033[96m {client_num}\033[93m IP:\033[0m" ) print(f"\033[93m╭───────────────────────────────────────╮\033[0m") for idx, ip in enumerate(ipoptions[client_num], start=1): print(f"{idx}. {ip}") print(f"\033[93m╰───────────────────────────────────────╯\033[0m") choice = ( int(input(f"\033[93mChoose IP [1-{len(ipoptions[client_num])}]: \033[0m")) - 1 ) server_ip = ipoptions[client_num][choice] server_port = input( f"\033[93mEnter \033[92mTunnel {client_num}\033[93m Port: \033[0m" ) client_public_ip = input( f"\033[93mEnter \033[92mIRAN \033[93mClient \033[96m{client_num}\033[93m IPV4: \033[0m" ) ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" print("\033[93m───────────────────────────────────────\033[0m") print( f"\033[93mSelect \033[92mClient IP \033[93mfor \033[97m IRAN Client \033[96m{client_num}\033[93m:\033[0m" ) print(f"\033[93m╭───────────────────────────────────────╮\033[0m") for idx, ip in enumerate(ipoptions[client_num], start=1): print(f"{idx}. {ip}") print(f"\033[93m╰───────────────────────────────────────╯\033[0m") choice = ( int(input(f"\033[93mChoose IP [1-{len(ipoptions[client_num])}]: \033[0m")) - 1 ) client_ip = ipoptions[client_num][choice] print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() in ["yes", "y"]: interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mKharej Server\033[97m Config \033[92m{client_num} \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mKharej Server\033[97m Config \033[92m{client_num} \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv6" def wg(client_num): try: disable_command = f"sudo systemctl stop wg-quick@wireserver{client_num}" daemon_reload_command = "sudo systemctl daemon-reload" enable_command = f"sudo systemctl enable wg-quick@wireserver{client_num}" restart_command = f"wg-quick up /etc/wireguard/wireserver{client_num}.conf" subprocess.run(disable_command, shell=True, check=True) subprocess.run(daemon_reload_command, shell=True, check=True) subprocess.run(enable_command, shell=True, check=True) subprocess.run(restart_command, shell=True, check=True) display_checkmark( f"\033[92mWireGuard configuration for wireserver\033[96m{client_num} activated\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError: failed to activate the service\033[0m") print( f"\033[97mSkipping the activation of wireserver\033[91m{client_num}\033[0m" ) # iran server kharej client def servernclient2_ipv6(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(f"\033[93mConfiguring Server & Client {client_num}\033[0m") server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mIRAN\033[93m Server\033[96m Config\033[97m {client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mKharej\033[93m Client\033[96m {client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" print("\033[93m───────────────────────────────────────\033[0m") print( f"\033[93mSelect \033[92mIRAN \033[93mServer \033[97mConfig\033[96m {client_num}\033[93m IP:\033[0m" ) print(f"\033[93m╭───────────────────────────────────────╮\033[0m") for idx, ip in enumerate(ipoptions[client_num], start=1): print(f"{idx}. {ip}") print(f"\033[93m╰───────────────────────────────────────╯\033[0m") choice = ( int(input(f"\033[93mChoose IP [1-{len(ipoptions[client_num])}]: \033[0m")) - 1 ) server_ip = ipoptions[client_num][choice] server_port = input( f"\033[93mEnter \033[92mTunnel {client_num}\033[93m Port: \033[0m" ) client_public_ip = input( f"\033[93mEnter \033[92mKharej \033[93mClient \033[96m{client_num}\033[93m IPV4: \033[0m" ) ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" print("\033[93m───────────────────────────────────────\033[0m") print( f"\033[93mSelect \033[92mClient IP \033[93mfor \033[97m IRAN Client \033[96m{client_num}\033[93m:\033[0m" ) print(f"\033[93m╭───────────────────────────────────────╮\033[0m") for idx, ip in enumerate(ipoptions[client_num], start=1): print(f"{idx}. {ip}") print(f"\033[93m╰───────────────────────────────────────╯\033[0m") choice = ( int(input(f"\033[93mChoose IP [1-{len(ipoptions[client_num])}]: \033[0m")) - 1 ) client_ip = ipoptions[client_num][choice] print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() in ["yes", "y"]: interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mIRAN Server\033[97m Config \033[92m{client_num} \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mIRAN Server\033[97m Config \033[92m{client_num} \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv6" def wireguardgre6tap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6tap + IPSEC \033[93mMenu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard + GRE6tap - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard + GRE6tap - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapkharej_wireguard_menu() break elif server_type == "2": gre6tapiran_wireguard_menu() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") def gre6tapkharej_wireguard_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6tap + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardgre6tap_iran_client1() break elif server_type == "2": wireguardgre6tap_iran_client2() break elif server_type == "3": wireguardgre6tap_iran_client3() break elif server_type == "4": wireguardgre6tap_iran_client4() break elif server_type == "5": wireguardgre6tap_iran_client5() break elif server_type == "6": wireguardgre6tap_kharej_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_mnu() break else: print("Invalid choice.") def wireguardgre6tap_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6tap \033[92mKharej Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_versions = set() server_ips = [] client_ips = [] num_clients = int( input("\033[93mEnter the number of \033[92mIRAN\033[93m Clients: \033[0m") ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient_ipv6(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) selected_server_num = num_clients for i in range(num_clients): menu_name = f"gre6tap2_kharej{i+1}_wireguard" if menu_name in globals(): globals()[menu_name](server_ips[i], client_ips[i]) else: print(f"\033[91merror: {menu_name} function not found!\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_ipsecn1k(psk, selected_server_num) restart_forced_strongazumi() ### no changes ### def user_input(prompt): return input(prompt).strip() def ip_choice_gre6tapwire(entity, ip_version, options): print( f"\033[93mChoose an \033[92mIP address \033[93mfor {entity} ({ip_version}):\033[0m" ) print("\033[93m╭───────────────────────────────────────╮\033[0m") for i, option in enumerate(options, 1): print(f"{i}) {option}") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = int(user_input("\033[93mEnter the number: \033[0m")) if choice == len(options): print("\033[93m───────────────────────────────────────\033[0m") return user_input( f"\033[93mEnter the custom \033[92m{ip_version} \033[93maddress for {entity}: \033[0m" ) return options[choice - 1] # changes starts def ipversion_n_address_gre6tapwire1(entity): ip_version = "ipv6" ip_options = ( ["2001:dc5::2", "fd1d::cd1::2", "manual"] if "Client" in entity else ["2001:dc5::1", "fd1d::cd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice_gre6tapwire(entity, ip_version, ip_options) return ip_address, subnet, ip_version # iran client 1 def wireguardgre6tap_iran_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mIRAN Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [1]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[1] Tunnel \033[93mport:\033[0m " ) ufwportudp(client_port) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire1( "\033[92mIRAN\033[93m Client \033[96m[1]\033[0m" ) ufw(client_ip) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire1( "\033[92mKharej Server\033[93m Config \033[96m[1]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_iran1_wireguard(client_ip, server_private_ip) def wgclient(): command = f"sudo systemctl enable wg-quick@wireclient" command = f"wg-quick up /etc/wireguard/wireclient.conf" subprocess.run(command, shell=True, check=True) # iran client 2 def ipversion_n_address_gre6tapwire2(entity): ip_version = "ipv6" ip_options = ( ["2001:de5::2", "fd1d::ed1::2", "manual"] if "Client" in entity else ["2001:de5::1", "fd1d::ed1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice_gre6tapwire(entity, ip_version, ip_options) return ip_address, subnet, ip_version # iran client 2 def wireguardgre6tap_iran_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mIRAN Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [2]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[2] Tunnel \033[93mport:\033[0m " ) ufwportudp(client_port) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire2( "\033[92mIRAN\033[93m Client \033[96m[2]\033[0m" ) ufw(client_ip) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire2( "\033[92mKharej Server\033[93m Config \033[96m[2]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_iran2_wireguard(client_ip, server_private_ip) # iran client 3 def ipversion_n_address_gre6tapwire3(entity): ip_version = "ipv6" ip_options = ( ["2001:df5::2", "fd1d::fd1::2", "manual"] if "Client" in entity else ["2001:df5::1", "fd1d::fd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice_gre6tapwire(entity, ip_version, ip_options) return ip_address, subnet, ip_version # iran client 3 def wireguardgre6tap_iran_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mIRAN Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [3]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[3] Tunnel \033[93mport:\033[0m " ) ufwportudp(client_port) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire3( "\033[92mIRAN\033[93m Client \033[96m[3]\033[0m" ) ufw(client_ip) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire3( "\033[92mKharej Server\033[93m Config \033[96m[3]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_iran3_wireguard(client_ip, server_private_ip) # iran client 4 def ipversion_n_address_gre6tapwire4(entity): ip_version = "ipv6" ip_options = ( ["2001:da5::2", "fd1d::ad1::2", "manual"] if "Client" in entity else ["2001:da5::1", "fd1d::ad1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice_gre6tapwire(entity, ip_version, ip_options) return ip_address, subnet, ip_version # iran client 4 def wireguardgre6tap_iran_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mIRAN Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [4]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[4] \033[93mTunnel port:\033[0m " ) ufwportudp(client_port) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire4( "\033[92mIRAN\033[93m Client \033[96m[4]\033[0m" ) ufw(client_ip) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire4( "\033[92mKharej Server\033[93m Config \033[96m[4]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_iran4_wireguard(client_ip, server_private_ip) # iran client 5 def ipversion_n_address_gre6tapwire5(entity): ip_version = "ipv6" ip_options = ( ["2001:db5::2", "fd1d::bd1::2", "manual"] if "Client" in entity else ["2001:db5::1", "fd1d::bd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice_gre6tapwire(entity, ip_version, ip_options) return ip_address, subnet, ip_version # iran client 5 def wireguardgre6tap_iran_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mIRAN Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [5]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[5] \033[93mTunnel port:\033[0m " ) ufwportudp(client_port) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire5( "\033[92mIRAN\033[93m Client \033[96m[5]\033[0m" ) ufw(client_ip) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire5( "\033[92mKharej Server\033[93m Config \033[96m[5]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_iran5_wireguard(client_ip, server_private_ip) # server kharej 1 def gre6tapk_tunnel1_wire(local_ip, remote_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) # server 2 kharej def gre6tapk_tunnel2_wire(local_ip, remote_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) # server 3 kharej def gre6tapk_tunnel3_wire(local_ip, remote_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:821a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) # server 4 kharej def gre6tapk_tunnel4_wire(local_ip, remote_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:831a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) # server 5 kharej def gre6tapk_tunnel5_wire(local_ip, remote_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:841a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) # this part can be removed later def gre61_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre61.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre61.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre62_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre62.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre62.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre63_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre63.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre63.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre64_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre64.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre64.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre65_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre65.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre65.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def ping_gre62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def ping_gre63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def ping_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def ping_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def create_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def create_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def create_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def create_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def create_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) #### # kharej side def kharej_gre6tapwire_tunnel1(local_ip, remote_ip): gre6tapk_tunnel1_wire(local_ip, remote_ip) ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() # kharej 2 def kharej_gre6tapwire_tunnel2(local_ip, remote_ip): gre6tapk_tunnel2_wire(local_ip, remote_ip) ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() # kahrej 3 def kharej_gre6tapwire_tunnel3(local_ip, remote_ip): gre6tapk_tunnel3_wire(local_ip, remote_ip) ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() # kharej 4 def kharej_gre6tapwire_tunnel4(local_ip, remote_ip): gre6tapk_tunnel4_wire(local_ip, remote_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() # kharej 5 def kharej_gre6tapwire_tunnel5(local_ip, remote_ip): gre6tapk_tunnel5_wire(local_ip, remote_ip) ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() # iran side def gre6tapi_tunnel1_wire(local_ip, remote_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tapwire_tunnel1(local_ip, remote_ip): gre6tapi_tunnel1_wire(local_ip, remote_ip) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() # iran server 2 def gre6tapi_tunnel2_wire(local_ip, remote_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:811a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tapwire_tunnel2(local_ip, remote_ip): gre6tapi_tunnel2_wire(local_ip, remote_ip) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() # iran server 3 def gre6tapi_tunnel3_wire(local_ip, remote_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:821a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tapwire_tunnel3(local_ip, remote_ip): gre6tapi_tunnel3_wire(local_ip, remote_ip) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() # iran server 4 def gre6tapi_tunnel4_wire(local_ip, remote_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:831a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tapwire_tunnel4(local_ip, remote_ip): gre6tapi_tunnel4_wire(local_ip, remote_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() # iran server5 def gre6tapi_tunnel5_wire(local_ip, remote_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:841a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tapwire_tunnel5(local_ip, remote_ip): gre6tapi_tunnel5_wire(local_ip, remote_ip) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def permissions1(): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def config_ipsecn_kharej1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap1 left=%defaultroute leftsubnet=2002:801a::1/64 leftid=2002:801a::1 right=2002:801a::2 rightsubnet=2002:801a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:801a::2 2002:801a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_kharej2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap2 left=%defaultroute leftsubnet=2002:811a::1/64 leftid=2002:811a::1 right=2002:811a::2 rightsubnet=2002:811a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::2 2002:811a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_kharej3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap3 left=%defaultroute leftsubnet=2002:821a::1/64 leftid=2002:821a::1 right=2002:821a::2 rightsubnet=2002:821a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:821a::2 2002:821a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_kharej4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gretap4 left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_kharej5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap5 left=%defaultroute leftsubnet=2002:841a::1/64 leftid=2002:841a::1 right=2002:841a::2 rightsubnet=2002:841a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:841a::2 2002:841a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_iran1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap1 left=%defaultroute leftsubnet=2002:801a::2/64 leftid=2002:801a::2 right=2002:801a::1 rightsubnet=2002:801a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:801a::1 2002:801a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_iran2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap2 left=%defaultroute leftsubnet=2002:811a::2/64 leftid=2002:811a::2 right=2002:811a::1 rightsubnet=2002:811a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::1 2002:811a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_iran3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap3 left=%defaultroute leftsubnet=2002:821a::2/64 leftid=2002:821a::2 right=2002:821a::1 rightsubnet=2002:821a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:821a::1 2002:821a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_iran4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap4 left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn_iran5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap5 left=%defaultroute leftsubnet=2002:841a::2/64 leftid=2002:841a::2 right=2002:841a::1 rightsubnet=2002:841a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:841a::1 2002:841a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # menu kharej 1 def gre6tap_kharej1_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_kharej1(psk) ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_kharej1_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_kharej2_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_kharej2(psk) ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_kharej2_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_kharej3_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_kharej3(psk) ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_kharej3_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_kharej4_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_kharej4(psk) ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_kharej4_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_kharej5_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_kharej5(psk) ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_kharej5_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # menu iran side def gre6tap_iran1_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_iran1(psk) ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran1_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_iran2_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_iran2(psk) ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran2_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_iran3_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_iran3(psk) ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran3_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_iran4_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_iran4(psk) ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran4_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_iran5_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn_iran5(psk) ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran5_wireguard(local_ip, remote_ip): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tapiran_wireguard_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6tap + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardgre6tap_kharej_client1() break elif server_type == "2": wireguardgre6tap_kharej_client2() break elif server_type == "3": wireguardgre6tap_kharej_client3() break elif server_type == "4": wireguardgre6tap_kharej_client4() break elif server_type == "5": wireguardgre6tap_kharej_client5() break elif server_type == "6": wireguardgre6tap_iran_server() break elif server_type == "0": os.system("clear") wireguardgre6tap_mnu() break else: print("Invalid choice.") def wireguardgre6tap_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6tap \033[92mIRAN Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_versions = set() server_ips = [] client_ips = [] num_clients = int( input("\033[93mEnter the number of \033[92mKharej\033[93m Clients: \033[0m") ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient2_ipv6(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) selected_server_num = num_clients for i in range(num_clients): menu_name = f"gre6tap2_iran{i+1}_wireguard" if menu_name in globals(): globals()[menu_name](server_ips[i], client_ips[i]) else: print(f"\033[91merror: {menu_name} function not found!\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, selected_server_num) restart_forced_strongazumi() # kharej client 1 def wireguardgre6tap_kharej_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mKharej Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [1]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[1] Tunnel \033[93mport:\033[0m " ) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire1( "\033[92mKharej\033[93m Client \033[96m[1]\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire1( "\033[92mIRAN Server\033[93m Config \033[96m[1]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_kharej1_wireguard(client_ip, server_private_ip) # kharej client 2 def wireguardgre6tap_kharej_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mKharej Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [2]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[2] Tunnel \033[93mport:\033[0m " ) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire2( "\033[92mKharej\033[93m Client \033[96m[2]\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire2( "\033[92mIRAN Server\033[93m Config \033[96m[2]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_kharej2_wireguard(client_ip, server_private_ip) # kharej client 3 def wireguardgre6tap_kharej_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mKharej Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [3]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[3] Tunnel \033[93mport:\033[0m " ) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire3( "\033[92mKharej\033[93m Client \033[96m[3]\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire3( "\033[92mIRAN Server\033[93m Config \033[96m[3]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_kharej3_wireguard(client_ip, server_private_ip) # kharej client 4 def wireguardgre6tap_kharej_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mKharej Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [4]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[4] \033[93mTunnel port:\033[0m " ) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire4( "\033[92mKharej\033[93m Client \033[96m[4]\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire4( "\033[92mIRAN Server\033[93m Config \033[96m[4]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_kharej4_wireguard(client_ip, server_private_ip) # kharej client 5 def wireguardgre6tap_kharej_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + Gre6tap \033[92mKharej Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [5]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mConfig \033[96m[5] \033[93mTunnel port:\033[0m " ) print("\033[93m───────────────────────────────────────\033[0m") client_ip, client_subnet, ip_version = ipversion_n_address_gre6tapwire5( "\033[92mKharej\033[93m Client \033[96m[5]\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") server_private_ip, server_subnet = ipversion_n_address_gre6tapwire5( "\033[92mIRAN Server\033[93m Config \033[96m[5]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) gre6tap_kharej5_wireguard(client_ip, server_private_ip) ##end def wireguardgre6tapnative_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6tap Native + IPSEC \033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print( "1. \033[92mWireguard + GRE6tap Native - [1]Kharej Server [5]IRAN Clients\033[0m" ) print( "2. \033[93mWireguard + GRE6tap Native - [1]IRAN Server [5]Kharej Clients\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapnativekharej_wireguard_menu() break elif server_type == "2": gre6tapnativeiran_wireguard_menu() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") def gre6tapnativekharej_wireguard_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap Native + Wireguard + IPSEC \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardgre6tap_nativeiran_client1() break elif server_type == "2": wireguardgre6tap_nativeiran_client2() break elif server_type == "3": wireguardgre6tap_nativeiran_client3() break elif server_type == "4": wireguardgre6tap_nativeiran_client4() break elif server_type == "5": wireguardgre6tap_nativeiran_client5() break elif server_type == "6": wireguardgre6tapnative_kharej_server() break elif server_type == "0": os.system("clear") wireguardgre6tapnative_mnu() break else: print("Invalid choice.") def servernclient_gre6tap(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mKharej\033[93m Server\033[96m Config\033[97m {client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mIRAN\033[93m Client\033[96m {client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver( f"\033[92mKharej \033[93mServer Config \033[96m{client_num}\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[93mServer Config {client_num}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) iran_client_ips_v6 = [ "2002:801a::2", "2002:811a::2", "2002:821a::2", "2002:831a::2", "2002:841a::2", ] ipversion = ipver(f"\033[92mIRAN \033[93mClient \033[96m{client_num} Config\033[0m") if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_privateip = iran_client_ips_v6[client_num - 1] client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mKharej Server\033[96m Config [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mKharej Server\033[96m Config [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def servernclient_gre6tap2(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mIRAN\033[93m Server\033[96m Config \033[97m{client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mKharej\033[93m Client \033[96m{client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver(f"\033[92mIRAN \033[93mServer Config \033[96m{client_num}\033[0m") if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[93mServer Config {client_num}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) iran_client_ips_v6 = [ "2002:801a::1", "2002:811a::1", "2002:821a::1", "2002:831a::1", "2002:841a::1", ] ipversion = ipver( f"\033[92mKharej \033[93mClient \033[96m{client_num} Config\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_privateip = iran_client_ips_v6[client_num - 1] client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mIRAN Server\033[96m Config [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mIRAN Server\033[96m Config [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def wireguardgre6tapnative_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + GRE6tap Native \033[92mKharej Server\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_clients = int( input("\033[93mEnter the number of \033[92mIRAN\033[93m Clients: \033[0m") ) for i in range(1, num_clients + 1): menu_name = f"gre6tap_nativekharej{i}_wireguard" if menu_name in globals(): globals()[menu_name]() else: print(f"Function {menu_name} does not exist.") server_ips = [] client_ips = [] ip_versions = set() for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient_gre6tap(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() config_server(psk, server_ips, client_ips, ip_ver) def wireguardgre6tap_nativeiran_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard \033[92mIRAN Client [1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativeiran1_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [1]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[1]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mIRAN Client \033[92m[1]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address( "\033[93mKharej Server Config \033[92m[1]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:801a::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativeiran_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard \033[92mIRAN Client [2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativeiran2_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [2]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[2]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mIRAN Client \033[92m[2]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mKharej Server Config \033[92m[2]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:811a::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativeiran_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard \033[92mIRAN Client [3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativeiran3_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [3]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[3]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mIRAN Client \033[92m[3]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mKharej Server Config \033[92m[3]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:821a::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativeiran_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard \033[92mIRAN Client [4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativeiran4_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [4]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[4]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mIRAN Client \033[92m[4]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mKharej Server Config \033[92m[4]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:831a::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativeiran_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard \033[92mIRAN Client [5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativeiran5_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [5]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[5]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mIRAN Client \033[92m[5]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mKharej Server Config \033[92m[5]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:841a::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def gre6tapnativeiran_wireguard_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap Native + Wireguard + IPSEC \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardgre6tap_nativekharej_client1() break elif server_type == "2": wireguardgre6tap_nativekharej_client2() break elif server_type == "3": wireguardgre6tap_nativekharej_client3() break elif server_type == "4": wireguardgre6tap_nativekharej_client4() break elif server_type == "5": wireguardgre6tap_nativekharej_client5() break elif server_type == "6": wireguardgre6tapnative_iran_server() break elif server_type == "0": os.system("clear") wireguardgre6tapnative_mnu() break else: print("Invalid choice.") def wireguardgre6tapnative_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + GRE6tap Native \033[92mIRAN Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_clients = int( input("\033[93mEnter the number of \033[92mKharej\033[93m Clients: \033[0m") ) for i in range(1, num_clients + 1): menu_name = f"gre6tap_nativeiran{i}_wireguard" if menu_name in globals(): globals()[menu_name]() else: print(f"Function {menu_name} does not exist.") server_ips = [] client_ips = [] ip_versions = set() for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient_gre6tap2(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() config_server(psk, server_ips, client_ips, ip_ver) def wireguardgre6tap_nativekharej_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard\033[92mKharej Client [1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativekharej1_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [1]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[1]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mKharej Client \033[92m[1]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address( "\033[93mIRAN Server Config \033[92m[1]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:801a::2:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativekharej_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard\033[92mKharej Client [2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativekharej2_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [2]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[2]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mKharej Client \033[92m[2]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mIRAN Server Config \033[92m[2]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:811a::2:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativekharej_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard\033[92mKharej Client [3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativekharej3_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [3]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[3]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mKharej Client \033[92m[3]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mIRAN Server Config \033[92m[3]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:821a::2:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativekharej_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard\033[92mKharej Client [4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativekharej4_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [4]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[4]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mKharej Client \033[92m[4]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mIRAN Server Config \033[92m[4]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:831a::2:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardgre6tap_nativekharej_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGre6tap Native + Wireguard\033[92mKharej Client [5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') gre6tap2_nativekharej5_wireguard() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [5]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[5]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mKharej Client \033[92m[5]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mIRAN Server Config \033[92m[5]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:841a::2:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def gre6tap_nativekharej1_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Server\033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[1]\033[93m IPV6 address: \033[0m" ) kharej_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativekharej1_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Client \033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") kharej_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativekharej2_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Server\033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[2]\033[93m IPV6 address: \033[0m" ) kharej_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativekharej2_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Client \033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") kharej_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m──────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativekharej3_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Server\033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[3]\033[93m IPV6 address: \033[0m" ) kharej_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativekharej3_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Client \033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") kharej_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativekharej4_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Server\033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[4]\033[93m IPV6 address: \033[0m" ) kharej_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativekharej4_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Client \033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") kharej_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativekharej5_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Server\033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[5]\033[93m IPV6 address: \033[0m" ) kharej_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativekharej5_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej Client \033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") kharej_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran side gre6tap native def gre6tap_nativeiran1_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client\033[96m [1]\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativeiran1_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[1] \033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel1(local_ip, remote_ip) ufw("2002:801a::2") ufw("2002:801a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativeiran2_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client\033[96m [2]\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativeiran2_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[2] \033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel2(local_ip, remote_ip) ufw("2002:811a::2") ufw("2002:811a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativeiran3_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client\033[96m [3]\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_iran3_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[3] \033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel3(local_ip, remote_ip) ufw("2002:821a::2") ufw("2002:821a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativeiran4_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client\033[96m [4]\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativeiran4_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[4] \033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel4(local_ip, remote_ip) ufw("2002:831a::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap_nativeiran5_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client\033[96m [5]\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_nativeiran5_wireguard(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + Native\033[93m Configuration\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[5] \033[93m IPV6 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV6 address: \033[0m" ) iran_gre6tapwire_tunnel5(local_ip, remote_ip) ufw("2002:841a::2") ufw("2002:841a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") ## Kharej 1 def run_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def add_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private1.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private1.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v61.service"]) subprocess.run(["systemctl", "start", "ping_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v61.service"]) ## Kharej 2 def run_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def add_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private2.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private2.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v62.service"]) subprocess.run(["systemctl", "start", "ping_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v62.service"]) def servernclient_sit(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mKharej\033[93m Server\033[96m Config\033[97m {client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mIRAN\033[93m Client\033[96m {client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver( f"\033[92mKharej \033[93mServer Config \033[96m{client_num}\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[92mServer\033[93m Config\033[96m {client_num}\033[0m", ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) iran_client_ips_v6 = [ "2002:801b::2", "2002:811b::2", "2002:821b::2", "2002:831b::2", "2002:841b::2", ] ipversion = ipver(f"\033[92mIRAN\033[93m Client \033[96m{client_num} Config\033[0m") if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_privateip = iran_client_ips_v6[client_num - 1] client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mKharej Server\033[96m Config [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mKharej Server\033[96m Config [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def servernclient_sit2(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mIRAN\033[93m Server\033[96m Config \033[97m{client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mKharej\033[93m Client \033[96m{client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver(f"\033[92mIRAN \033[93mServer Config \033[96m{client_num}\033[0m") if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[92mServer \033[93mConfig {client_num}\033[0m", ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) iran_client_ips_v6 = [ "2002:801b::1", "2002:811b::1", "2002:821b::1", "2002:831b::1", "2002:841b::1", ] ipversion = ipver( f"\033[92mKharej\033[93m Client \033[96m{client_num} Config\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_privateip = iran_client_ips_v6[client_num - 1] client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mIRAN Server\033[96m Config [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mIRAN Server\033[96m Config [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_privateip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def wireguardsit_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT + IPSEC \033[93mMenu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard + SIT - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard + SIT - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_sit_kharej1_5iran() break elif server_type == "2": wireguard_sit_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") def wireguard_sit_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardsit_iran_client1() break elif server_type == "2": wireguardsit_iran_client2() break elif server_type == "3": wireguardsit_iran_client3() break elif server_type == "4": wireguardsit_iran_client4() break elif server_type == "5": wireguardsit_iran_client5() break elif server_type == "6": wireguardsit_kharej_server() break elif server_type == "0": os.system("clear") wireguardsit_menu() break else: print("Invalid choice.") def wireguardsit_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mKharej Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_clients = int( input("\033[93mEnter the number of \033[92mIRAN\033[93m Clients: \033[0m") ) for i in range(1, num_clients + 1): menu_name = f"kharejserver{i}_wireguardsit_menu" if menu_name in globals(): globals()[menu_name]() else: print(f"Function {menu_name} does not exist.") server_ips = [] client_ips = [] ip_versions = set() for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient_sit(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() config_server(psk, server_ips, client_ips, ip_ver) def wireguardsit_iran_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') iranclient1_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [1]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[1]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mIRAN Client \033[92m[1]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address( "\033[93mKharej Server Config \033[92m[1]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:801b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_iran_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') iranclient2_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [2]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[2]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mIRAN Client \033[92m[2]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mKharej Server Config \033[92m[2]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:811b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_iran_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') iranclient3_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [3]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[3]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mIRAN Client \033[92m[3]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mKharej Server Config \033[92m[3]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:821b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_iran_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') iranclient4_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [4]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[4]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mIRAN Client \033[92m[4]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mKharej Server Config \033[92m[4]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:831b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_iran_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') iranclient5_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [5]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[5]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mIRAN Client \033[92m[5]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mKharej Server Config \033[92m[5]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:841b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def kharejserver1_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m Kharej server\033[96m Config \033[92m[1]\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Server \033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() ufw("2002:801b::2") ufw("2002:801b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:801b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejserver2_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m Kharej server\033[96m Config \033[92m[2]\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Server \033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() ufw("2002:811b::2") ufw("2002:811b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:811b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejserver3_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m Kharej server\033[96m Config \033[92m[3]\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Server \033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() ufw("2002:821b::2") ufw("2002:821b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:821b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejserver4_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m Kharej server\033[96m Config \033[92m[4]\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Server \033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() ufw("2002:831b::2") ufw("2002:831b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:831b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejserver5_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m Kharej server\033[96m Config \033[92m[5]\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Server \033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() ufw("2002:841b::2") ufw("2002:841b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:841b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran client 1 sit def iranclient1_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT IRAN Client\033[96m[1]\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1_iran() ufw("2002:801b::2") ufw("2002:801b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:801b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() def iranclient2_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT IRAN Client\033[96m[2]\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2_iran() ufw("2002:811b::2") ufw("2002:811b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:811b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() def iranclient3_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT IRAN Client\033[96m[3]\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3_iran() ufw("2002:821b::2") ufw("2002:821b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:821b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() def iranclient4_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT IRAN Client\033[96m[4]\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4_iran() ufw("2002:831b::2") ufw("2002:831b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:831b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() def iranclient5_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT IRAN Client\033[96m[5]\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Client \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5_iran() ufw("2002:841b::2") ufw("2002:841b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:841b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() # opposite def wireguard_sit_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard + SIT \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguardsit_kharej_client1() break elif server_type == "2": wireguardsit_kharej_client2() break elif server_type == "3": wireguardsit_kharej_client3() break elif server_type == "4": wireguardsit_kharej_client4() break elif server_type == "5": wireguardsit_kharej_client5() break elif server_type == "6": wireguardsit_iran_server() break elif server_type == "0": os.system("clear") wireguardsit_menu() break else: print("Invalid choice.") def wireguardsit_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mIRAN Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_clients = int( input("\033[93mEnter the number of \033[92mIRAN\033[93m Clients: \033[0m") ) for i in range(1, num_clients + 1): menu_name = f"iranserver{i}_wireguardsit_menu" if menu_name in globals(): globals()[menu_name]() else: print(f"Function {menu_name} does not exist.") server_ips = [] client_ips = [] ip_versions = set() for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient_sit2(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() config_server(psk, server_ips, client_ips, ip_ver) def wireguardsit_kharej_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mKharej Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') kharejclient1_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [1]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[1]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mKharej Client \033[92m[1]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address( "\033[93mIRAN Server Config \033[92m[1]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:801b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_kharej_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mKharej Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') kharejclient2_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [2]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[2]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mKharej Client \033[92m[2]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mIRAN Server Config \033[92m[2]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:811b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_kharej_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + SIT \033[92mKharej Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') kharejclient3_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [3]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[3]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mKharej Client \033[92m[3]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mIRAN Server Config \033[92m[3]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:821b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_kharej_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') kharejclient4_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [4]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[4]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mKharej Client \033[92m[4]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mIRAN Server Config \033[92m[4]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:831b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def wireguardsit_kharej_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') kharejclient5_wireguardsit_menu() check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [5]\033[93m private key:\033[0m " ) client_port = user_input( "\033[93mEnter \033[92mConfig \033[96m[5]\033[93m Tunnel port:\033[0m " ) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mKharej Client \033[92m[5]\033[0m" ) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mIRAN Server Config \033[92m[5]\033[0m" )[:2] ufwportudp(client_port) ufw(client_ip) ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = 2002:841b::1:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client(psk, [server_private_ip], [client_ip], ip_version) def iranserver1_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m IRAN server\033[96m Config \033[92m[1]\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() ufw("2002:801b::2") ufw("2002:801b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:801b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranserver2_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m IRAN server\033[96m Config \033[92m[2]\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() ufw("2002:811b::2") ufw("2002:811b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:811b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranserver3_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m IRAN server\033[96m Config \033[92m[3]\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() ufw("2002:821b::2") ufw("2002:821b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:821b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranserver4_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m IRAN server\033[96m Config \033[92m[4]\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() ufw("2002:831b::2") ufw("2002:831b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:831b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranserver5_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( "\033[93mConfiguring \033[97mSIT\033[93m IRAN server\033[96m Config \033[92m[5]\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN Server \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() ufw("2002:841b::2") ufw("2002:841b::1") display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:841b::1 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # kharej client 1 sit def kharejclient1_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT Kharej Client\033[96m[1]\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1_iran() ufw("2002:801b::2") ufw("2002:801b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:801b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() def kharejclient2_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT Kharej Client\033[96m[2]\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2_iran() ufw("2002:811b::2") ufw("2002:811b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:811b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() def kharejclient3_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT Kharej Client\033[96m[3]\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3_iran() ufw("2002:821b::2") ufw("2002:821b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:821b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() def kharejclient4_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT Kharej Client\033[96m[4]\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4_iran() ufw("2002:831b::2") ufw("2002:831b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:831b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() def kharejclient5_wireguardsit_menu(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring SIT Kharej Client\033[96m[5]\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej Client \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [SIT]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5_iran() ufw("2002:841b::2") ufw("2002:841b::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2002:841b::2 " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() def get_default_interface(): try: output = subprocess.check_output(["ip", "route", "show", "default"]).decode() lines = output.strip().split("\n") for line in lines: if "default via" in line: parts = line.split() interface = parts[4] return interface except subprocess.CalledProcessError: pass return None def has_ipv4_address(interface): addresses = netifaces.ifaddresses(interface) return netifaces.AF_INET in addresses def main_interface(): default_interface = get_default_interface() if default_interface and has_ipv4_address(default_interface): return default_interface return None def ask_interface(): find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) def wireguardudp_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard + IPSEC \033[93mMenu\033[0m") print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mWireguard - [1]Kharej Server [5]IRAN Clients\033[0m") print("2. \033[93mWireguard - [1]IRAN Server [5]Kharej Clients\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_noconjuction_kharej1_5iran() break elif server_type == "2": wireguard_noconjuction_1iran_5kharej() break elif server_type == "0": os.system("clear") wireguard_allinone_mnu() break else: print("Invalid choice.") def display_checkmark(message): print("\u2714 " + message) def check_wireguard_installed(): try: subprocess.check_output(["dpkg", "-s", "wireguard"]) print("\033[92mWireGuard is already installed\033[0m") except subprocess.CalledProcessError: print("\033[93mWireGuard is not installed. \033[92mInstalling now...\033[0m") install_wireguard() def update_package_list(): print("\033[93mUpdating package list...\033[0m") wire(["sudo", "apt-get", "update", "-y"]) def sync_system_time(): print("\033[93mSynchronizing system time...\033[0m") try: subprocess.run( ["ntpdate", "--version"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) except subprocess.CalledProcessError: print("\033[91m'ntpdate' is not installed. installing it now..\033[0m") subprocess.run(["sudo", "apt-get", "update", "-y"], check=True) subprocess.run(["sudo", "apt-get", "install", "-y", "ntpdate"], check=True) subprocess.run(["sudo", "ntpdate", "pool.ntp.org"], check=True) print("\033[92mSystem time synchronized successfully.\033[0m") def add_wireguard_repository(): print("\033[93mAdding WireGuard repository...\033[0m") command = ["sudo", "tee", "/etc/apt/sources.list.d/wireguard.list"] process = subprocess.Popen(command, stdin=subprocess.PIPE) process.communicate(input=b"deb http://deb.debian.org/debian/ bullseye main\n") if process.returncode != 0: print("\033[91mFailed to add WireGuard repository\033[0m") else: print("\033[92mWireGuard repository added\033[0m") wire(["sudo", "apt-get", "update"]) def install_wireguard(): update_package_list() command = ["sudo", "apt-get", "install", "wireguard", "-y"] result = wire(command) if "Unable to locate package wireguard" in result: sync_system_time() add_wireguard_repository() sync_system_time() update_package_list() wire(command) print("\033[92mWireGuard is installed\033[0m") def wire(command): process = subprocess.Popen( command, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE ) _, stderr = process.communicate() if process.returncode != 0: print(f"\033[91mError: {stderr.decode()}\033[0m") return stderr.decode() def hide(command): process = subprocess.Popen( command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE ) while process.poll() is None: anime() _, stderr = process.communicate() if process.returncode != 0: print(f"\033[91merror: {stderr.decode()}\033[0m") def generate_keys(): private_key = ( subprocess.check_output("wg genkey", shell=True).strip().decode("utf-8") ) public_key = ( subprocess.check_output(f"echo {private_key} | wg pubkey", shell=True) .strip() .decode("utf-8") ) return private_key, public_key def keynconfig(keypath, content): with open(keypath, "w") as file: file.write(content) def display_notification(message): print("\u2728 " + message) def ipver(iptype): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(f"\033[93mChoose IP version for {iptype}:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1)\033[93m IPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = int( input("\033[93mChoose \033[96m1\033[93m or\033[96m 2\033[93m: \033[0m") ) return choice def ipaddr(ipversion, options, iptype): version = "IPv4" if ipversion == 1 else "IPv6" print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(f"\033[93mChoose a {version} address for {iptype}:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") for i, option in enumerate(options, 1): print(f"{i}) {option}") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = int(input("\033[93mPlease choose: \033[0m")) if choice == len(options): print( "\033[93m─────────────────────────────────────────────────────────\033[0m" ) return input( f"\033[93mEnter the Manual {version} address for {iptype}: \033[0m" ) return options[choice - 1] def animate(message): for char in message: print(char, end="", flush=True) time.sleep(0.05) print() def anime(): animation = [ "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[======]", "[===== ]", "[==== ]", "[=== ]", "[== ]", "[= ]", ] for i in range(20): time.sleep(0.1) sys.stdout.write(f"\r{animation[i % len(animation)]}") sys.stdout.flush() sys.stdout.write("\r") sys.stdout.flush() def config_server_wireguard(psk, server_ips, client_ips, ip_ver): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mInstalling IPSEC..\033[0m") os.system("sudo apt install strongswan -y") print("\033[92mIPSEC Installation is completed!\033[0m") os.system("sudo systemctl disable strongswan-starter > /dev/null 2>&1") os.system("sudo systemctl stop strongswan-starter > /dev/null 2>&1") os.system("sudo systemctl disable strongswan > /dev/null 2>&1") os.system("sudo systemctl stop strongswan > /dev/null 2>&1") os.system("sudo rm -f /etc/ipsec1.conf /etc/ipsec.secrets > /dev/null 2>&1") subnet = "32" if ip_ver == "ipv4" else "64" ipsec_conf = """config setup charondebug=all uniqueids=no ##azumiisinyourarea\n\n""" for i, (server_ip, client_ip) in enumerate(zip(server_ips, client_ips), 1): ipsec_conf += f"""conn wireguard_server{i} left=%defaultroute leftsubnet={server_ip}/{subnet} leftid={server_ip} right={client_ip} rightsubnet={client_ip}/{subnet} ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n\n""" with open("/etc/ipsec1.conf", "w") as f: f.write(ipsec_conf) with open("/etc/ipsec.secrets", "w") as f: for server_ip, client_ip in zip(server_ips, client_ips): f.write(f'{client_ip} {server_ip} : PSK "{psk}"\n') service_content = """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write(service_content) os.system("sudo systemctl daemon-reload") os.system("sudo systemctl enable strong-azumi1") os.system("sudo systemctl restart strong-azumi1") def servernclient(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mKharej\033[93m Server\033[96m Config\033[97m {client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mIRAN\033[93m Client\033[96m {client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver( f"\033[92mKharej \033[93mServer Config \033[96m{client_num}\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[92mKharej \033[93mServer Config \033[96m{client_num}\033[0m", ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) client_public_ip = input( f"\033[93mEnter \033[92mIRAN \033[96m{client_num} \033[93mIPV4: \033[0m" ) ipversion = ipver(f"\033[92mIRAN \033[93mClient \033[96m{client_num} Config\033[0m") if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mKharej Server\033[96m Config [{client_num}] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mKharej Server\033[96m Config [{client_num}] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def servernclient2(client_num): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification( f"\033[93mConfiguring \033[96mWireguard \033[92mServer & Client \033[96m{client_num}\033[0m" ) server_private_key, server_public_key = generate_keys() client_private_key, client_public_key = generate_keys() print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[92mIRAN\033[93m Server\033[96m Config \033[97m{client_num}\033[93m Keys:\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {server_private_key}\033[0m") print(f" Public Key:\033[96m {server_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") print(f"\033[92mKharej\033[93m Client \033[96m{client_num}\033[93m Keys:\033[0m") print(f"\033[93m───────────────────────────────────────\033[0m") print( f"\033[93m╭──────────────────────────────────────────────────────────╮\033[0m" ) print(f" Private Key:\033[96m {client_private_key}\033[0m") print(f" Public Key:\033[96m {client_public_key}\033[0m") print( f"\033[93m╰──────────────────────────────────────────────────────────╯\033[0m" ) ipversion = ipver( f"\033[92mKharej\033[93m Server Config \033[96m{client_num}\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.1", "172.168.0.1", "manual"], 2: ["60.3.0.1", "172.168.1.1", "manual"], 3: ["60.4.0.1", "172.168.2.1", "manual"], 4: ["60.5.0.1", "172.168.3.1", "manual"], 5: ["60.6.0.1", "172.168.4.1", "manual"], } subnet = "24" else: ipoptions = { 1: ["2001:dc5::1", "fd1d:cd1::1", "manual"], 2: ["2001:de5::1", "fd1d:ed1::1", "manual"], 3: ["2001:df5::1", "fd1d:fd1::1", "manual"], 4: ["2001:da5::1", "fd1d:ad1::1", "manual"], 5: ["2001:db5::1", "fd1d:bd1::1", "manual"], } subnet = "64" server_ip = ipaddr( ipversion, ipoptions[client_num], f"\033[92mIRAN Server Config \033[96m{client_num}\033[0m", ) print(f"\033[93m───────────────────────────────────────\033[0m") server_port = input( f"\033[93mEnter \033[92mConfig \033[96m{client_num}\033[93m Tunnel Port: \033[0m" ) client_public_ip = input( f"\033[93mEnter \033[92mKharej \033[96m{client_num} \033[93mIPV4: \033[0m" ) ipversion = ipver( f"\033[92mKharej \033[93mClient \033[96m{client_num} Config\033[0m" ) if ipversion == 1: ipoptions = { 1: ["60.2.0.2", "172.168.0.2", "manual"], 2: ["60.3.0.2", "172.168.1.2", "manual"], 3: ["60.4.0.2", "172.168.2.2", "manual"], 4: ["60.5.0.2", "172.168.3.2", "manual"], 5: ["60.6.0.2", "172.168.4.2", "manual"], } client_subnet = "32" else: ipoptions = { 1: ["2001:dc5::2", "fd1d:cd1::2", "manual"], 2: ["2001:de5::2", "fd1d:ed1::2", "manual"], 3: ["2001:df5::2", "fd1d:fd1::2", "manual"], 4: ["2001:da5::2", "fd1d:ad1::2", "manual"], 5: ["2001:db5::2", "fd1d:bd1::2", "manual"], } client_subnet = "128" client_ip = ipaddr(ipversion, ipoptions[client_num], f"Client {client_num}") print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mIRAN Server\033[96m Config [{client_num}] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mIRAN Server\033[96m Config [{client_num}] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" if ipversion == 1: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ else: server_config = f""" [Interface] PrivateKey = {server_private_key} Address = {server_ip}/{subnet} ListenPort = {server_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {server_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostUp = iptables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireserver{client_num} -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {server_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireserver{client_num} -j ACCEPT PostDown = iptables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireserver{client_num} -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {client_public_key} AllowedIPs = {client_ip}/{client_subnet} Endpoint = {client_public_ip}:{server_port} """ server_confpath = f"/etc/wireguard/wireserver{client_num}.conf" keynconfig(server_confpath, server_config) ufwportudp(server_port) wg(client_num) return server_ip, client_ip, "ipv4" if ipversion == 1 else "ipv6" def wireguard_noconjuction_kharej1_5iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard \033[92m[1]Kharej Server\033[96m [5]IRAN Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN Client [1] Config\033[0m") print("2. \033[92mIRAN Client [2] Config\033[0m") print("3. \033[92mIRAN Client [3] Config\033[0m") print("4. \033[93mIRAN Client [4] Config\033[0m") print("5. \033[92mIRAN Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_iran_client1() break elif server_type == "2": wireguard_iran_client2() break elif server_type == "3": wireguard_iran_client3() break elif server_type == "4": wireguard_iran_client4() break elif server_type == "5": wireguard_iran_client5() break elif server_type == "6": wireguard_kharej_server() break elif server_type == "0": os.system("clear") wireguardudp_menu() break else: print("Invalid choice.") # ping and service for wireguard def create_wireguardping_server(ip_address, client_number): file_path = f"/etc/ping_wireguard_{client_number}.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings=2 interval=10 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def wireguardping_server_service(client_number): service_content = f"""[Unit] Description=keepalive for client {client_number} After=network.target [Service] ExecStart=/bin/bash /etc/ping_wireguard_{client_number}.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = f"/etc/systemd/system/wireguardping_{client_number}.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", f"wireguardping_{client_number}.service"]) subprocess.run(["systemctl", "start", f"wireguardping_{client_number}.service"]) subprocess.run(["systemctl", "restart", f"wireguardping_{client_number}.service"]) def ufw(ip_address): subprocess.run(["sudo", "ufw", "allow", "from", ip_address]) def wireguard_kharej_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_versions = set() server_ips = [] client_ips = [] num_clients = int( input("\033[93mEnter the number of \033[92mIRAN Clients\033[93m: \033[0m") ) for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) server_confpath = f"/etc/wireguard/wireserver{num_clients}.conf" display_checkmark( f"\033[92mServer configuration saved to \033[97m{server_confpath}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() if ip_versions else "ipv4" config_server_wireguard(psk, server_ips, client_ips, ip_ver) enable_reset_ipsec() def user_input(prompt): return input(prompt).strip() def ip_choice(entity, ip_version, options): print(f"\033[93mChoose an IP address for {entity} ({ip_version}):\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") for i, option in enumerate(options, 1): print(f"{i}) {option}") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = int(user_input("\033[93mEnter the number: \033[0m")) if choice == len(options): print("\033[93m───────────────────────────────────────\033[0m") return user_input( f"\033[93mEnter the custom \033[92m{ip_version} \033[93maddress for {entity}: \033[0m" ) return options[choice - 1] def config_client_wireguard(psk, server_ips, client_ips, ip_ver): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mInstalling IPSEC..\033[0m") os.system("sudo apt install strongswan -y") print("\033[92mIPSEC Installation is completed!\033[0m") os.system("sudo systemctl disable strongswan-starter > /dev/null 2>&1") os.system("sudo systemctl stop strongswan-starter > /dev/null 2>&1") os.system("sudo systemctl disable strongswan > /dev/null 2>&1") os.system("sudo systemctl stop strongswan > /dev/null 2>&1") os.system("sudo rm -f /etc/ipsec1.conf /etc/ipsec.secrets > /dev/null 2>&1") subnet = "32" if ip_ver == "ipv4" else "64" ipsec_conf = """config setup charondebug=all uniqueids=no ##azumiisinyourarea\n\n""" for server_ip, client_ip in zip(server_ips, client_ips): ipsec_conf += f"""conn wireguard_client left=%defaultroute leftsubnet={client_ip}/{subnet} leftid={client_ip} right={server_ip} rightsubnet={server_ip}/{subnet} ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n\n""" with open("/etc/ipsec1.conf", "w") as f: f.write(ipsec_conf) with open("/etc/ipsec.secrets", "w") as f: for server_ip, client_ip in zip(server_ips, client_ips): f.write(f'{server_ip} {client_ip} : PSK "{psk}"\n') service_content = """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write(service_content) os.system("sudo systemctl daemon-reload") os.system("sudo systemctl enable strong-azumi1") os.system("sudo systemctl restart strong-azumi1") def ipversion_n_address(entity): print("\033[93m───────────────────────────────────────\033[0m") print(f"\033[93m{entity} IP Version:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1) \033[93mIPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") ip_version_choice = user_input( "\033[93mChoose IP version (\033[92m1\033[93m or\033[96m 2\033[93m):\033[0m " ).strip() if ip_version_choice == "1": ip_version = "ipv4" ip_options = ( ["60.2.0.2", "172.168.0.2", "manual"] if "Client" in entity else ["60.2.0.1", "172.168.0.1", "manual"] ) subnet = "24" if "Client" in entity else "32" else: ip_version = "ipv6" ip_options = ( ["2001:dc5::2", "fd1d:cd1::2", "manual"] if "Client" in entity else ["2001:dc5::1", "fd1d:cd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice(entity, ip_version, ip_options) return ip_address, subnet, ip_version def create_wireguardping_client(ip_address): file_path = "/etc/ping_wireguard.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings=2 interval=10 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def wireguardping_client_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_wireguard.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/wireguardping.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "wireguardping.service"]) subprocess.run(["systemctl", "start", "wireguardping.service"]) subprocess.run(["systemctl", "restart", "wireguardping.service"]) def ufwportudp(port): try: subprocess.run(["sudo", "ufw", "allow", f"{port}/udp"], check=True) except subprocess.CalledProcessError as e: print(f"Warning: prolly ufw prog is not installed, Continuing script...") def wireguard_iran_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [1]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[1] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mIRAN Client \033[92m[1]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address( "\033[93mKharej Server Config \033[92m[1]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # iran client 2 def ipversion_n_address2(entity): print("\033[93m───────────────────────────────────────\033[0m") print(f"\033[93m{entity} IP Version:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1) \033[93mIPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") ip_version_choice = user_input( "\033[93mChoose IP version (\033[92m1\033[93m or\033[96m 2\033[93m):\033[0m " ).strip() if ip_version_choice == "1": ip_version = "ipv4" ip_options = ( ["60.3.0.2", "172.168.1.2", "manual"] if "Client" in entity else ["60.3.0.1", "172.168.1.1", "manual"] ) subnet = "24" if "Client" in entity else "32" else: ip_version = "ipv6" ip_options = ( ["2001:de5::2", "fd1d:ed1::2", "manual"] if "Client" in entity else ["2001:de5::1", "fd1d:ed1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice(entity, ip_version, ip_options) return ip_address, subnet, ip_version def wireguard_iran_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [2]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[2] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mIRAN Client \033[92m[2]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mKharej Server Config \033[92m[2]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # iran client 3 def ipversion_n_address3(entity): print("\033[93m───────────────────────────────────────\033[0m") print(f"\033[93m{entity} IP Version:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1) \033[93mIPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") ip_version_choice = user_input( "\033[93mChoose IP version (\033[92m1\033[93m or\033[96m 2\033[93m):\033[0m " ).strip() if ip_version_choice == "1": ip_version = "ipv4" ip_options = ( ["60.4.0.2", "172.168.2.2", "manual"] if "Client" in entity else ["60.4.0.1", "172.168.2.1", "manual"] ) subnet = "24" if "Client" in entity else "32" else: ip_version = "ipv6" ip_options = ( ["2001:df5::2", "fd1d:fd1::2", "manual"] if "Client" in entity else ["2001:df5::1", "fd1d:fd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice(entity, ip_version, ip_options) return ip_address, subnet, ip_version def wireguard_iran_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [3]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[3] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mIRAN Client \033[92m[3]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mKharej Server Config \033[92m[3]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # iran client 4 def ipversion_n_address4(entity): print("\033[93m───────────────────────────────────────\033[0m") print(f"\033[93m{entity} IP Version:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1) \033[93mIPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") ip_version_choice = user_input( "\033[93mChoose IP version (\033[92m1\033[93m or\033[96m 2\033[93m):\033[0m " ).strip() if ip_version_choice == "1": ip_version = "ipv4" ip_options = ( ["60.5.0.2", "172.168.3.2", "manual"] if "Client" in entity else ["60.5.0.1", "172.168.3.1", "manual"] ) subnet = "24" if "Client" in entity else "32" else: ip_version = "ipv6" ip_options = ( ["2001:da5::2", "fd1d:ad1::2", "manual"] if "Client" in entity else ["2001:da5::1", "fd1d:ad1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice(entity, ip_version, ip_options) return ip_address, subnet, ip_version def wireguard_iran_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [4]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[4] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mIRAN Client \033[92m[4]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mKharej Server Config \033[92m[4]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # iran client 5 def ipversion_n_address5(entity): print("\033[93m───────────────────────────────────────\033[0m") print(f"\033[93m{entity} IP Version:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1) \033[93mIPv4\033[0m") print("2) \033[93mIPv6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") ip_version_choice = user_input( "\033[93mChoose IP version (\033[92m1\033[93m or\033[96m 2\033[93m):\033[0m " ).strip() if ip_version_choice == "1": ip_version = "ipv4" ip_options = ( ["60.6.0.2", "172.168.4.2", "manual"] if "Client" in entity else ["60.6.0.1", "172.168.4.1", "manual"] ) subnet = "24" if "Client" in entity else "32" else: ip_version = "ipv6" ip_options = ( ["2001:db5::2", "fd1d:bd1::2", "manual"] if "Client" in entity else ["2001:db5::1", "fd1d:bd1::1", "manual"] ) subnet = "64" if "Client" in entity else "128" ip_address = ip_choice(entity, ip_version, ip_options) return ip_address, subnet, ip_version def wireguard_iran_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mKharej Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mIRAN Client\033[96m [5]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mKharej Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[5] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mIRAN Client \033[92m[5]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mKharej Server Config \033[92m[5]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() def wireguard_noconjuction_1iran_5kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mWireguard \033[92m[1]IRAN Server\033[96m [5]Kharej Client\033[93mMenu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej Client [1] Config\033[0m") print("2. \033[92mKharej Client [2] Config\033[0m") print("3. \033[92mKharej Client [3] Config\033[0m") print("4. \033[93mKharej Client [4] Config\033[0m") print("5. \033[92mKharej Client [5] Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN Server Config\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0.\033[97mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": wireguard_kharej_client1() break elif server_type == "2": wireguard_kharej_client2() break elif server_type == "3": wireguard_kharej_client3() break elif server_type == "4": wireguard_kharej_client4() break elif server_type == "5": wireguard_kharej_client5() break elif server_type == "6": wireguard_iran_server() break elif server_type == "0": os.system("clear") wireguardudp_menu() break else: print("Invalid choice.") def wireguard_iran_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mIRAN Server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_versions = set() server_ips = [] client_ips = [] num_clients = int( input("\033[93mEnter the number of \033[92mKharej Clients\033[93m: \033[0m") ) for i in range(1, num_clients + 1): server_ip, client_ip, ip_version = servernclient2(i) server_ips.append(server_ip) client_ips.append(client_ip) ip_versions.add(ip_version) create_wireguardping_server(client_ip, i) wireguardping_server_service(i) ufw(server_ip) ufw(client_ip) server_confpath = f"/etc/wireguard/wireserver{num_clients}.conf" display_checkmark( f"\033[92mServer configuration saved to \033[97m{server_confpath}\033[0m" ) print(f"\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") ip_ver = ip_versions.pop() if ip_versions else "ipv4" config_server_wireguard(psk, server_ips, client_ips, ip_ver) enable_reset_ipsec() def wireguard_kharej_client1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [1]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[1] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [1]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[1] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address( "\033[93mKharej Client \033[92m[1]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address( "\033[93mIRAN Server Config \033[92m[1]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [1] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [1] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # kharej client 2 def wireguard_kharej_client2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [2]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[2] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [2]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[2] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address2( "\033[93mKharej Client \033[92m[2]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address2( "\033[93mIRAN Server Config \033[92m[2]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [2] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [2] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # kharej client 3 def wireguard_kharej_client3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [3]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[3] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [3]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[3] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address3( "\033[93mKharej Client \033[92m[3]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address3( "\033[93mIRAN Server Config \033[92m[3]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [3] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [3] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # kharej client 4 def wireguard_kharej_client4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [4]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[4] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [4]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[4] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address4( "\033[93mKharej Client \033[92m[4]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address4( "\033[93mIRAN Server Config \033[92m[4]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [4] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [4] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() # kharej client 5 def wireguard_kharej_client5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mWireguard \033[92mKharej Client [5]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') check_wireguard_installed() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring WireGuard Client\033[0m") print("\033[93m───────────────────────────────────────\033[0m") server_public_key = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m's config \033[96m[5] \033[96mpublic key:\033[0m " ) client_private_key = user_input( "\033[93mEnter \033[92mKharej Client\033[96m [5]\033[93m private key:\033[0m " ) server_public_ip = user_input( "\033[93mEnter \033[92mIRAN Server\033[93m IPV4 address:\033[0m " ) client_port = user_input( "\033[93mEnter the \033[92mTunnel config \033[96m[5] \033[93mport:\033[0m " ) ufwportudp(client_port) client_ip, client_subnet, ip_version = ipversion_n_address5( "\033[93mKharej Client \033[92m[5]\033[0m" ) ufw(client_ip) server_private_ip, server_subnet = ipversion_n_address5( "\033[93mIRAN Server Config \033[92m[5]\033[0m" )[:2] ufw(server_private_ip) print("\033[93m───────────────────────────────────────\033[0m") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") mtu_config = "" mtu_choice = input( f"\033[93mDo you want to set \033[92mWireguard MTU\033[93m for \033[92mClient\033[96m [5] \033[93m(\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if mtu_choice in ["yes", "y"]: mtu_value = input( f"\033[93mEnter MTU value for \033[92mClient\033[96m [5] \033[93m: \033[0m" ) mtu_config = f"MTU = {mtu_value}\n" client_config = f""" [Interface] PrivateKey = {client_private_key} Address = {client_ip}/{client_subnet} ListenPort = {client_port} {mtu_config} PostUp = iptables -I INPUT -p udp --dport {client_port} -j ACCEPT PostUp = iptables -I FORWARD -i {interface} -o wireclient -j ACCEPT PostUp = iptables -I FORWARD -i wireclient -j ACCEPT PostUp = iptables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostUp = ip6tables -I FORWARD -i wireclient -j ACCEPT PostUp = ip6tables -t nat -A POSTROUTING -o {interface} -j MASQUERADE PostDown = iptables -D INPUT -p udp --dport {client_port} -j ACCEPT PostDown = iptables -D FORWARD -i {interface} -o wireclient -j ACCEPT PostDown = iptables -D FORWARD -i wireclient -j ACCEPT PostDown = iptables -t nat -D POSTROUTING -o {interface} -j MASQUERADE PostDown = ip6tables -D FORWARD -i wireclient -j ACCEPT PostDown = ip6tables -t nat -D POSTROUTING -o {interface} -j MASQUERADE [Peer] PublicKey = {server_public_key} AllowedIPs = {server_private_ip}/{server_subnet} Endpoint = {server_public_ip}:{client_port} """ client_config_path = "/etc/wireguard/wireclient.conf" write_config(client_config_path, client_config) wgclient() create_wireguardping_client(server_private_ip) wireguardping_client_service() print("\033[93m───────────────────────────────────────\033[0m") display_checkmark( f"\033[92mClient configuration saved to \033[97m{client_config_path}\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipsec_choice = ( input( "\033[93mDo you want to configure IPsec? (\033[92myes\033[93m or \033[91mno): \033[0m" ) .strip() .lower() ) if ipsec_choice in ["yes", "y"]: psk = input("\033[93mEnter IPSEC \033[92mSecret Key\033[93m: \033[0m") config_client_wireguard(psk, [server_private_ip], [client_ip], ip_version) enable_reset_ipsec() def write_config(file_path, content): with open(file_path, "w") as file: file.write(content) ##wireguard end ####Edit def edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mSingle\033[0m") print("2. \033[93mMulti\033[0m") print("3. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": single_edit_local() break elif choice == "2": multi_edit_local() break elif choice == "3": clear() main_menu() break else: print("Invalid choice.") def clear(): subprocess.run(["clear"]) def single_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Single Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mPrivate\033[93m[Sit]\033[0m") print("2. \033[93mIP6IP6\033[0m") print("3. \033[92mGRE6\033[0m") print("4. \033[93mGRE6TAP IPV4\033[0m") print("5. \033[93mGRE6TAP Native\033[0m") print("6. \033[92mGeneve UDP \033[0m") print("7. \033[93mIPV4 + Geneve + GRE6 [Private IPV6]\033[0m") print("8. \033[92mVxlan FDB\033[0m") print("9. \033[93mVxlan P2P\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": private_edit_local() break elif choice == "2": ip6ip6_edit_local() break elif choice == "3": gre6_edit_local() break elif choice == "4": gre6tap_edit_local() break elif choice == "5": gre6tapn_edit_local() break elif choice == "6": gen_edit_localmenu() break elif choice == "7": gengre_edit_local() break elif choice == "8": vxfdb_edit_local() break elif choice == "9": vxp2p_edit_local() break elif choice == "0": clear() edit_local() break else: print("Invalid choice.") def private_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatenosec_edit_local() break elif choice == "2": privatesec_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def privatenosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatenosec_edit_localkharej() break elif choice == "2": privatenosec_edit_localiran() break elif choice == "3": clear() private_edit_local() break else: print("Invalid choice.") def privatesec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatesec_edit_localkharej() break elif choice == "2": privatesec_edit_localiran() break elif choice == "3": clear() private_edit_local() break else: print("Invalid choice.") def wtb_opposite_ip(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi?", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips(): private_ip_private = private_ip("/etc/private.sh") return { "private": private_ip_private, } def delete_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_sit(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfile_sit(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_privateiran(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKHAREJ Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[92mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_checkmark(message): print("\u2714 " + message) def animate(message): for char in message: print(char, end="", flush=True) time.sleep(0.05) print() def save_stuff_sit(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_sit("/etc/private.sh", private_ip, update_type="private") update_ipfile_sit("/etc/private.sh", local_ip, update_type="local") update_ipfile_sit("/etc/private.sh", remote_ip, update_type="remote") interface = "azumi" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v6"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def privatenosec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def privatenosec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") # ipsec sit menu def ipsecsecret_key(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipsecsecret(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_sitv6(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_sit("/etc/private.sh", private_ip, update_type="private") update_ipfile_sit("/etc/private.sh", local_ip, update_type="local") update_ipfile_sit("/etc/private.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec.conf", private_ip) interface = "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v6"], check=True) subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print( f"error applying network stuff: {e.stderr.strip() if e.stderr else str(e)}" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_ipsecsecret(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def privatesec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def privatesec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") # ipip def ip6ip6_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ipipnosec_edit_local() break elif choice == "2": ipipsec_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def ipipsec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ipipsec_edit_localkharej() break elif choice == "2": ipipsec_edit_localiran() break elif choice == "3": clear() ip6ip6_edit_local() break else: print("Invalid choice.") def private_ipip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumip?", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_ipip(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip("/etc/ipip.sh", new_ip, update_type="ipip_local") update_ipfile_ipip( "/etc/ipip.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip(): private_ip_private = private_ipip("/etc/private.sh") private_ip_ipip = private_ipip("/etc/ipip.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipsec(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_ipip("/etc/ipip.sh", private_ip, update_type="private") update_ipfile_ipip("/etc/ipip.sh", remote_ip, update_type="remote") update_ipfile_ipip("/etc/ipsec.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_ipip("/etc/private.sh", private_ip, update_type="private") update_ipfile_ipip("/etc/private.sh", local_ip, update_type="local") update_ipfile_ipip("/etc/private.sh", remote_ip, update_type="remote") interface = "azumip" if is_ipip else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip.sh" if is_ipip else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], check=True ) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["sudo", "systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def display_stuff_ip6ip6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: IP6IP6 Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def get_ipsecsecret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(.*)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def ipipsec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_ipip = local_ip("/etc/ipip.sh") remote_ip_ipip = remote_ip("/etc/ipip.sh") private_ip_ipip = private_ipip("/etc/ipip.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipsec( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False ) save_stuff_ipipsec( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def ipipsec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_ipip = local_ip("/etc/ipip.sh") remote_ip_ipip = remote_ip("/etc/ipip.sh") private_ip_ipip = private_ipip("/etc/ipip.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipsec( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False ) save_stuff_ipipsec( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def ipipnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ipipnosec_edit_localkharej() break elif choice == "2": ipipnosec_edit_localiran() break elif choice == "3": clear() ip6ip6_edit_local() break else: print("Invalid choice.") def save_stuff_ipip(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_ipip("/etc/ipip.sh", private_ip, update_type="private") update_ipfile_ipip("/etc/ipip.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_ipip("/etc/private.sh", private_ip, update_type="private") update_ipfile_ipip("/etc/private.sh", local_ip, update_type="local") update_ipfile_ipip("/etc/private.sh", remote_ip, update_type="remote") interface = "azumip" if is_ipip else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/ipip.sh" if is_ipip else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipnosec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_ipip = local_ip("/etc/ipip.sh") remote_ip_ipip = remote_ip("/etc/ipip.sh") private_ip_ipip = private_ipip("/etc/ipip.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False ) save_stuff_ipip( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipnosec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_ipip = local_ip("/etc/ipip.sh") remote_ip_ipip = remote_ip("/etc/ipip.sh") private_ip_ipip = private_ipip("/etc/ipip.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False ) save_stuff_ipip( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6nosec_edit_local() break elif choice == "2": gre6sec_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def gre6sec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6sec_edit_localkharej() break elif choice == "2": gre6sec_edit_localiran() break elif choice == "3": clear() gre6_edit_local() break else: print("Invalid choice.") def private_gre6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumig6", content) if match: return match.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumi", content) if match: return match.group(1) else: print("\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_gre6(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6("/etc/gre6.sh", new_ip, update_type="gre6_local") update_ipfile_gre6( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre6(): private_ip_private = private("/etc/private.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre6() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_gre6("/etc/gre6.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/gre6.sh", remote_ip, update_type="remote") update_ipfile_gre6("/etc/ipsec.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_gre6("/etc/private.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/private.sh", local_ip, update_type="local") update_ipfile_gre6("/etc/private.sh", remote_ip, update_type="remote") interface = "azumig6" if is_gre6 else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], check=True ) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["sudo", "systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def display_stuff_gre6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6 Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def get_ipsecsecret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(.*)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def gre6sec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6sec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6nosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6nosec_edit_localkharej() break elif choice == "2": gre6nosec_edit_localiran() break elif choice == "3": clear() gre6_edit_local() break else: print("Invalid choice.") def save_stuff_gre6(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre6() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_gre6("/etc/gre6.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/gre6.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_gre6("/etc/private.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/private.sh", local_ip, update_type="local") update_ipfile_gre6("/etc/private.sh", remote_ip, update_type="remote") interface = "azumig6" if is_gre6 else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6nosec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre6( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6nosec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre6( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tap_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosec_edit_local() break elif choice == "2": gre6tapsec_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def gre6tapsec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapsec_edit_localkharej() break elif choice == "2": gre6tapsec_edit_localiran() break elif choice == "3": clear() gre6tap_edit_local() break else: print("Invalid choice.") def private_gre6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumig6", content) if match: return match.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumi", content) if match: return match.group(1) else: print("\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_gre6(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre6("/etc/gre6.sh", new_ip, update_type="gre6_local") update_ipfile_gre6( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre6(): private_ip_private = private("/etc/private.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre6() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_gre6("/etc/gre6.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/gre6.sh", remote_ip, update_type="remote") update_ipfile_gre6("/etc/ipsec.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_gre6("/etc/private.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/private.sh", local_ip, update_type="local") update_ipfile_gre6("/etc/private.sh", remote_ip, update_type="remote") interface = "azumig6" if is_gre6 else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"Changes saved and {interface} interface updated successfully!" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], check=True ) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["sudo", "systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def display_stuff_gre6tap(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def get_ipsecsecret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(.*)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def gre6tapsec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapsec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosec_edit_localkharej() break elif choice == "2": gre6tapnosec_edit_localiran() break elif choice == "3": clear() gre6tap_edit_local() break else: print("Invalid choice.") def save_stuff_gre6tap(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre6() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip.sh", counterpart_ip) update_ipfile_gre6("/etc/gre6.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/gre6.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v6.sh", counterpart_ip) update_ipfile_gre6("/etc/private.sh", private_ip, update_type="private") update_ipfile_gre6("/etc/private.sh", local_ip, update_type="local") update_ipfile_gre6("/etc/private.sh", remote_ip, update_type="remote") interface = "azumig6" if is_gre6 else "azumi" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"Changes saved and {interface} interface updated successfully!" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v6"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network changes: {e.stderr.strip() if e.stderr else str(e)}\033[0m" ) except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6tapnosec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre6( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapnosec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre6( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapn_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Native Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosecn_edit_local() break elif choice == "2": gre6tapsecn_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def gre6tapnosecn_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Native Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosecn_edit_localkharej() break elif choice == "2": gre6tapnosecn_edit_localiran() break elif choice == "3": clear() gre6tapn_edit_local() break else: print("Invalid choice.") def gre6tapnosecn_edit_localkharej(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_kh(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP Native\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IPV6 :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IPV6 :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapnosecn_edit_localiran(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_ir(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP Native\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapsecn_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Native IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapsecn_edit_localkharej() break elif choice == "2": gre6tapsecn_edit_localiran() break elif choice == "3": clear() gre6tapn_edit_local() break else: print("Invalid choice.") def display_stuff_gre6tapn_ir(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IPV6: \033[97m{local_ip}\033[0m", f"\033[92mKharej IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gre6tapn_kh(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IPV6: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IPV6: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def gre6tapsecn_edit_localkharej(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_kh(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP Native + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IPV6 :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IPV6 :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "5": save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapsecn_edit_localiran(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_ir(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP Native + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre6("/etc/ipsec.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "5": save_stuff_gre6sec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gre6tapnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Native Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosecn_edit_localkharej() break elif choice == "2": gre6tapnosecn_edit_localiran() break elif choice == "3": clear() gre6tapn_edit_local() break else: print("Invalid choice.") def gre6tapnosec_edit_localkharej(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_kh(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapnosec_edit_localiran(): local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_gre6tapn_ir(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IPV6\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IPV6\033[0m") print("3. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6TAP]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_gre6( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gen_edit_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve Private IPV4 \033[96m[Point IP]\033[0m") print("2. \033[93mGeneve Private IPV6 \033[96m[Point IP]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gen_edit_local() break elif choice == "2": gen_edit_localv6() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def gen_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_local() break elif choice == "2": genudpsec_edit_local() break elif choice == "3": clear() gen_edit_localmenu() break else: print("Invalid choice.") def genudpnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_localkharej() break elif choice == "2": genudpnosec_edit_localiran() break elif choice == "3": clear() gen_edit_local() break else: print("Invalid choice.") def private_gen(name): try: with open(name, "r") as f: content = f.read() match_v4 = re.search( r"ip addr add (\d+\.\d+\.\d+\.\d+)/32 dev azumigen", content ) match_v6 = re.search(r"ip addr add (\S+::\d+)/64 dev azumigen", content) if match_v4: return match_v4.group(1) elif match_v6: return match_v6.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def private_gen_nosec(name): try: with open(name, "r") as f: content = f.read() match_v4 = re.search( r"ip addr add (\d+\.\d+\.\d+\.\d+)/32 dev azumigen", content ) match_v6 = re.search(r"ip addr add (\S+::\d+)/16 dev azumigen", content) if match_v4: return match_v4.group(1) elif match_v6: return match_v6.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_gen(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": if ":" in new_ip: new_content = re.sub( r"ip addr add \S+/64 dev azumigen", f"ip addr add {new_ip}/64 dev azumigen", content, ) ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip route add \S+/64 dev azumigen", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) else: new_content = re.sub( r"ip addr add \d+\.\d+\.\d+\.\d+/32 dev azumigen", f"ip addr add {new_ip}/32 dev azumigen", content, ) ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"ip route add \d+\.\d+\.\d+\.\d+/32 dev azumigen", f"ip route add {counterpart_ip}/32 dev azumigen", new_content, ) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgen(): private_ip_geneve = private_gen("/etc/sys.sh") return { "geneve": private_ip_geneve, } def display_stuff_genk(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_geni(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen(private_ip, remote_ip): current_ips = get_current_private_ipsgen() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys.sh", remote_ip, update_type="remote") interface = "azumigen" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: Unit ping_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print( f"\033[91merror applying network stuff: {e.stderr.strip() if e.stderr else e}\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpnosec_edit_localiran(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_genk(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen(private_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def genudpnosec_edit_localkharej(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_geni(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen(private_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def ipsec_secret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "([^"]+)"', content) if match: return match.group(1) else: print("\033[91mno IPSec secret found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_gensec(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": if ":" in new_ip: new_content = re.sub( r"ip addr add \S+/64 dev azumigen", f"ip addr add {new_ip}/64 dev azumigen", content, ) ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip route add \S+/64 dev azumigen", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) else: new_content = re.sub( r"ip addr add \d+\.\d+\.\d+\.\d+/32 dev azumigen", f"ip addr add {new_ip}/32 dev azumigen", content, ) ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"ip route add \d+\.\d+\.\d+\.\d+/32 dev azumigen", f"ip route add {counterpart_ip}/32 dev azumigen", new_content, ) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": if ":" in new_ip: ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) new_content = re.sub( r"right=\S+", f"right={counterpart_ip}", new_content ) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) else: ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_ip}/32", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) new_content = re.sub( r"right=\S+", f"right={counterpart_ip}", new_content ) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/32", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_secret(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "[^"]+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: Unit ping_gen.service not found.\033[0m" ) else: raise subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], check=True ) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in (result.stdout or ""): subprocess.run(["sudo", "systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print( f"\033[91merror applying network stuff: {e.stderr.strip() if e.stderr else e}\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_k(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_i(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpsec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V4 IPSEC Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpsec_edit_localkharej() break elif choice == "2": genudpsec_edit_localiran() break elif choice == "3": clear() gen_edit_local() break else: print("Invalid choice.") def genudpsec_edit_localiran(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def genudpsec_edit_localkharej(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gen_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_localv6() break elif choice == "2": genudpsec_edit_localv6() break elif choice == "3": clear() gen_edit_localmenu() break else: print("Invalid choice.") def genudpnosec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_localkharejv6() break elif choice == "2": genudpnosec_edit_localiranv6() break elif choice == "3": clear() gen_edit_localv6() break else: print("Invalid choice.") def genudpnosec_edit_localiranv6(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_genk(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen(private_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def genudpnosec_edit_localkharejv6(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_geni(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen(private_ip_private, remote_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def genudpsec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V6 IPSEC Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpsec_edit_localkharejv6() break elif choice == "2": genudpsec_edit_localiranv6() break elif choice == "3": clear() gen_edit_localv6() break else: print("Invalid choice.") def genudpsec_edit_localiranv6(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def wtb_opposite_ipgen(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def update_pingfilegen(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpsec_edit_localkharejv6(): remote_ip_private = remote_ip("/etc/sys.sh") private_ip_private = private_gen("/etc/sys.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def gengre_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengrenosec_edit_local() break elif choice == "2": gengresec_edit_local() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def gengrenosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengrenosec_edit_localkharej() break elif choice == "2": gengrenosec_edit_localiran() break elif choice == "3": clear() gengre_edit_local() break else: print("Invalid choice.") def gengresec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve GRE6 + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengresec_edit_localkharej() break elif choice == "2": gengresec_edit_localiran() break elif choice == "3": clear() gengre_edit_local() break else: print("Invalid choice.") def update_ipfilegengre_nosec(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec("/etc/gre6.sh", new_ip, update_type="gre6_local") update_ipfilegengre_nosec( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/16 dev azumigen", f"ip addr add {new_ip}/16 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/16 dev azumigen", f"ip route add {counterpart_ip}/16 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfile_gengrenosec(name, ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "geneve": new_content = re.sub(r"remote \S+", f"remote {ip}", content) elif update_type == "geneve_opposite": opposite_ip = wtb_opposite_ip_gengrenosec(ip) new_content = re.sub(r"remote \S+", f"remote {opposite_ip}", content) elif update_type == "ping_ip": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_v6": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_sys_opposite": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) else: print("\033[91mInvalid update type for pingfile\033[0m") return with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip_gengrenosec(ip): ip_parts = ip.split(":") if ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" return ":".join(ip_parts) def save_stuff_gengrenosec( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregennosec() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec( "/etc/gre6.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec("/etc/gre6.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec( "/etc/sys.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec( "/etc/sys.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v6.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec( "/etc/private.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec("/etc/private.sh", local_ip, update_type="local") update_ipfilegengre_nosec( "/etc/private.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig6" if is_gre6 else "azumi" if is_geneve: interface = "azumigen" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" if is_geneve: script = "/etc/sys.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v6"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v6\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) display_checkmark("\033[92mping_ip service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_geneve_greiran(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_geneve_greiran(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def gengrenosec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip1("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") remote_ip_geneve = remote_ip("/etc/sys.sh") private_ip_geneve = private_gen_nosec("/etc/sys.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrenosec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip1("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") remote_ip_geneve = remote_ip("/etc/sys.sh") private_ip_geneve = private_gen_nosec("/etc/sys.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def get_current_private_ipsgregennosec(): private_ip_private = private_ip1("/etc/private.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") private_ip_geneve = private_gen_nosec("/etc/sys.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def get_current_private_ipsgregen(): private_ip_private = private_ip1("/etc/private.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") private_ip_geneve = private_gen("/etc/spn.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen("/etc/gre6.sh", new_ip, update_type="gre6_local") update_ipfilegregen( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfilegregen(name, ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "geneve": new_content = re.sub(r"remote \S+", f"remote {ip}", content) elif update_type == "geneve_opposite": opposite_ip = wtb_opposite_ipgregen(ip) new_content = re.sub(r"remote \S+", f"remote {opposite_ip}", content) elif update_type == "ping_ip": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_v6": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_sys_opposite": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) else: print("\033[91mInvalid update type for pingfile\033[0m") return with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ipgregen(ip): ip_parts = ip.split(":") if ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" return ":".join(ip_parts) def save_stuff_gregen(new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False): current_ips = get_current_private_ipsgregen() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen("/etc/gre6.sh", new_private_ip, update_type="private") update_ipfilegregen("/etc/gre6.sh", remote_ip, update_type="remote") update_ipfilegregen( "/etc/spn.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping_espan.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping_espan.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen( "/etc/spn.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping_espan.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre("/etc/ipsec.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v6.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen( "/etc/private.sh", new_private_ip, update_type="private" ) update_ipfilegregen("/etc/private.sh", local_ip, update_type="local") update_ipfilegregen("/etc/private.sh", remote_ip, update_type="remote") update_ipfilegregen( "/etc/gre6.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping_espan.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig6" if is_gre6 else "azumi" if is_geneve: interface = "azumigen" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre6.sh" if is_gre6 else "/etc/private.sh" if is_geneve: script = "/etc/spn.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v6"], check=True) print("\033[92m✔ ping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v6\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_espan"], check=True) print("\033[92m✔ ping_espan service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_espan not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_espan\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip"], check=True) print("\033[92m✔ ping_ip service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip\033[0m") subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def update_ipsec_confgengre(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipsecsit": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipsecsit' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipsecsit' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_ipsecsecretgengre(secret_key): print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") def update_ipsecsecret(name, new_key): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK ".*"', f'PSK "{new_key}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengresec_edit_localiran(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip1("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") remote_ip_geneve = remote_ip("/etc/spn.sh") private_ip_geneve = private_gen("/etc/spn.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengresec_edit_localkharej(): local_ip_private = local_ip("/etc/private.sh") remote_ip_private = remote_ip("/etc/private.sh") private_ip_private = private_ip1("/etc/private.sh") local_ip_gre6 = local_ip("/etc/gre6.sh") remote_ip_gre6 = remote_ip("/etc/gre6.sh") private_ip_gre6 = private_gre6("/etc/gre6.sh") remote_ip_geneve = remote_ip("/etc/spn.sh") private_ip_geneve = private_gen("/etc/spn.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() single_edit_local() break else: print("Invalid choice. Please select a valid option.") def vxp2p_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan P2P Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mVxlan \033[96m[Private IPV4]\033[0m") print("2. \033[93mVxlan \033[96m[Private IPV6]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxp2p_edit_localv4() break elif choice == "2": vxp2p_edit_localv6() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def vxp2p_edit_localv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlannosec_edit_local() break elif choice == "2": vxlansec_edit_local() break elif choice == "3": clear() vxp2p_edit_local() break else: print("Invalid choice.") def vxlannosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlannosec_edit_localkharej() break elif choice == "2": vxlannosec_edit_localiran() break elif choice == "3": clear() vxp2p_edit_localv4() break else: print("Invalid choice.") def vxlan_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/24 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_dev_dstport(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"dev (\S+) dstport (\d+)", content) if match: return match.group(1), match.group(2) else: print(f"\033[91mno device or destination port found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None, None def get_current_vxlan_ips(): vxlan_ip_bridge = vxlan_ip("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def delete_ufw_rulesvx(ip, port): counterpart_ip = wtb_opposite_ipvx(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", f"{ip}"], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", f"{counterpart_ip}"], check=False ) subprocess.run(["sudo", "ufw", "delete", "allow", f"{port}"], check=False) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rulesvx(ip, port): counterpart_ip = wtb_opposite_ipvx(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", f"{ip}"], check=True) subprocess.run( ["sudo", "ufw", "allow", "from", f"{counterpart_ip}"], check=True ) subprocess.run(["sudo", "ufw", "allow", f"{port}"], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_vx(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/24 dev vxlan", f"ip addr add {new_ip}/24 dev vxlan", content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfile_vx(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033{0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_vxlaniran(local_ip, remote_ip, vxlan_ip, dev, dstport): lines = [ f"\033[93mTitle: Vxlan Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{vxlan_ip}\033[0m", f"\033[93mDevice: \033[97m{dev}\033[0m", f"\033[93mDestination Port \033[97m{dstport}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_vxlankharej(local_ip, remote_ip, vxlan_ip, dev, dstport): lines = [ f"\033[93mTitle: Vxlan Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IP: \033[97m{local_ip}\033[0m", f"\033[92mIRAN IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{vxlan_ip}\033[0m", f"\033[93mDevice: \033[97m{dev}\033[0m", f"\033[93mDestination Port \033[97m{dstport}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_vx6(vxlan_ip, local_ip, remote_ip, dev, dstport, current_dstport): current_ips = get_current_vxlan_ips6() current_ip = current_ips.get("vxlan") if current_ip: delete_ufw_rulesvx(current_ip, current_dstport) add_ufw_rulesvx(vxlan_ip, dstport) counterpart_ip = wtb_opposite_ipvx(vxlan_ip) try: update_pingfile_vx("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_vx6("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_vx6("/usr/local/bin/bridge.sh", local_ip, update_type="local") update_ipfile_vx6("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") with open("/usr/local/bin/bridge.sh", "r") as f: content = f.read() new_content = re.sub( r"dev \S+ dstport \d+", f"dev {dev} dstport {dstport}", content ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write(new_content) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mError bringing interface down or deleting it\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def save_stuff_vx(vxlan_ip, local_ip, remote_ip, dev, dstport, current_dstport): current_ips = get_current_vxlan_ips() current_ip = current_ips.get("vxlan") if current_ip: delete_ufw_rulesvx(current_ip, current_dstport) add_ufw_rulesvx(vxlan_ip, dstport) counterpart_ip = wtb_opposite_ipvx(vxlan_ip) try: update_pingfile_vx("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_vx("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_vx("/usr/local/bin/bridge.sh", local_ip, update_type="local") update_ipfile_vx("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") with open("/usr/local/bin/bridge.sh", "r") as f: content = f.read() new_content = re.sub( r"dev \S+ dstport \d+", f"dev {dev} dstport {dstport}", content ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write(new_content) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mError bringing interface down or deleting it\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def vxlannosec_edit_localiran(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN P2P V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New IPv4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter new device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter new destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": save_stuff_vx( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxlannosec_edit_localkharej(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlankharej( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN P2P V4\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New IPv4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter new device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter new destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": save_stuff_vx( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def wtb_opposite_ipvx(ip): if ":" in ip: ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def vxp2p_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlannosec_edit_localv6() break elif choice == "2": vxlansec_edit_localv6() break elif choice == "3": clear() vxp2p_edit_local() break else: print("Invalid choice.") def vxlannosec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlannosec_edit_localkharejv6() break elif choice == "2": vxlannosec_edit_localiranv6() break elif choice == "3": clear() vxp2p_edit_localv6() break else: print("Invalid choice.") def vxlan_ipv6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/64 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_vxlan_ips6(): vxlan_ip_bridge = vxlan_ipv6("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def update_ipfile_vx6(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/64 dev vxlan", f"ip addr add {new_ip}/64 dev vxlan", content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def vxlannosec_edit_localiranv6(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ipv6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport ): print( "Couldn't retrieve IP addresses or device or destination port from Vxlan file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN P2P V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New IPv6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter new device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter new destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": save_stuff_vx6( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxlannosec_edit_localkharejv6(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ipv6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport ): print( "Couldn't retrieve IP addresses or device or destination port from Vxlan file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlankharej( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN P2P V6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New IPv6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter new device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter new destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": save_stuff_vx6( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxlansec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan + IPSEC V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlansec_edit_localkharej() break elif choice == "2": vxlansec_edit_localiran() break elif choice == "3": clear() vxp2p_edit_localv4() break else: print("Invalid choice.") def ipsecsecret_key(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033{0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipsecsecret_vxsec(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_vxsec(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_parts = new_private_ip.split(".") if new_private_ip.endswith(".2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/32", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/32", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ipvxsec(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def save_stuff_vxsec4( vxlan_ip, local_ip, remote_ip, dev, dstport, current_dstport, ipsecsecret ): current_ips = get_current_vxlan_ips() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rulesvx(current_ip, current_dstport) add_ufw_rulesvx(vxlan_ip, dstport) counterpart_ip = wtb_opposite_ip(vxlan_ip) try: update_pingfile_vx("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_vx("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_vx("/usr/local/bin/bridge.sh", local_ip, update_type="local") update_ipfile_vx("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipsecsecret_vxsec("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_vxsec("/etc/ipsec.conf", vxlan_ip) with open("/usr/local/bin/bridge.sh", "r") as f: content = f.read() new_content = re.sub( r"dev \S+ dstport \d+", f"dev {dev} dstport {dstport}", content ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write(new_content) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mError bringing interface down or deleting it\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark( "\033[92mping_vxlan service restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Service ping_vxlan not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def vxlansec_edit_localiran(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport or not ipsecsecret_key_private ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN + IPSEc\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV4\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPV4 \033[96m[Vxlan]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033{0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter New device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter New destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "7": save_stuff_vxsec4( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ipsecsecret_key_private, ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxlansec_edit_localkharej(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport or not ipsecsecret_key_private ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN + IPSEc\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV4\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPV4 \033[96m[Vxlan]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033{0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter New device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter New destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "7": save_stuff_vxsec4( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ipsecsecret_key_private, ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxlansec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan + IPSEC V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxlansec_edit_localkharejv6() break elif choice == "2": vxlansec_edit_localiranv6() break elif choice == "3": clear() vxp2p_edit_localv6() break else: print("Invalid choice.") def save_stuff_vxsec6( vxlan_ip, local_ip, remote_ip, dev, dstport, current_dstport, ipsecsecret ): current_ips = get_current_vxlan_ips6() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rulesvx(current_ip, current_dstport) add_ufw_rulesvx(vxlan_ip, dstport) counterpart_ip = wtb_opposite_ip(vxlan_ip) try: update_pingfile_vx("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_vx6("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_vx6("/usr/local/bin/bridge.sh", local_ip, update_type="local") update_ipfile_vx6("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipsecsecret_vxsec("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_vxsec6("/etc/ipsec.conf", vxlan_ip) with open("/usr/local/bin/bridge.sh", "r") as f: content = f.read() new_content = re.sub( r"dev \S+ dstport \d+", f"dev {dev} dstport {dstport}", content ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write(new_content) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mError bringing interface down or deleting it\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark( "\033[92mping_vxlan service restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Service ping_vxlan not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def update_ipsec_conf_vxsec6(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_parts = new_private_ip.split(":") if new_private_ip.endswith("::2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsecip_vxsec(path, new_private_ip, remote_ip): try: with open(path, "r") as f: content = f.read() new_content = re.sub( r'\S+ \S+ : PSK "azumi"', f'{new_private_ip} {remote_ip} : PSK "azumi"', content, ) with open(path, "w") as f: f.write(new_content) return new_content except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def vxlansec_edit_localiranv6(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ipv6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport or not ipsecsecret_key_private ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN + IPSEC V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPV6 \033[96m[Vxlan]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033{0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKHAREJ\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter New device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter New destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "7": save_stuff_vxsec6( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ipsecsecret_key_private, ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def update_ipsec_ip(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] for line in lines: if ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def vxlansec_edit_localkharejv6(): local_ip_vxlan = local_ip("/usr/local/bin/bridge.sh") remote_ip_vxlan = remote_ip("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ipv6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_vxlan or not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport or not ipsecsecret_key_private ): print( "Couldn't retrieve IP addresses or device or destination port from VXLAN file" ) return current_dstport = dstport while True: os.system("clear") display_stuff_vxlaniran( local_ip_vxlan, remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN + IPSEC V6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3. \033[93mChange \033[97mVxlan \033[93mPrivate IPV6\033[0m") print("4. \033[93mChange \033[97mDevice name\033[0m") print("5. \033[93mChange \033[97mDestination Port\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPV6 \033[96m[Vxlan]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033{0m ") if new_ip: local_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": dev = input("\033[93mEnter New device name (example: eth0) :\033[0m ") elif choice == "5": new_dstport = input("\033[93mEnter New destination port :\033[0m ") if new_dstport: dstport = new_dstport else: print("\033[91mWrong port number\033[0m") elif choice == "6": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "7": save_stuff_vxsec4( vxlan_ip_vxlan, local_ip_vxlan, remote_ip_vxlan, dev, dstport, current_dstport, ipsecsecret_key_private, ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxfdb_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mVxlan \033[96m[Private IPV4]\033[0m") print("2. \033[93mVxlan \033[96m[Private IPV6]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxfdb_edit_localv4() break elif choice == "2": vxfdb_edit_localv6() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def vxfdb_edit_localv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_local() break elif choice == "2": fdbsec_edit_local() break elif choice == "3": clear() vxfdb_edit_local() break else: print("Invalid choice.") def fdbnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localkharej() break elif choice == "2": fdbnosec_edit_localiran() break elif choice == "3": clear() vxfdb_edit_localv4() break else: print("Invalid choice.") def vxfdb_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localv6() break elif choice == "2": fdbsec_edit_localv6() break elif choice == "3": clear() vxfdb_edit_local() break else: print("Invalid choice.") def fdbnosec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localkharejv6() break elif choice == "2": fdbnosec_edit_localiranv6() break elif choice == "3": clear() vxfdb_edit_localv6() break else: print("Invalid choice.") def wtb_opposite_ipfdb(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def remote_ip_fdb(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"dst (\S+) dev vxlan", content) if match: return match.group(1) else: print("\033[91mno remote IP found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def vxlan_ip_fdb(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/24 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def vxlan_ip_fdb6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/64 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_dev_vxlan_dstport(name): try: with open(name, "r") as f: content = f.read() dev_match = re.search(r"dev (\S+)", content) dstport_match = re.search(r"dstport (\d+)", content) dev = dev_match.group(1) if dev_match else None dstport = dstport_match.group(1) if dstport_match else None return dev, dstport except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None, None def get_current_vxlan_ips_fdb(): vxlan_ip_bridge = vxlan_ip_fdb("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def get_current_vxlan_ips_fdb6(): vxlan_ip_bridge = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def delete_ufw_rules_fdb(ip): counterpart_ip = wtb_opposite_ipfdb(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules_fdb(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_fdb(name, new_ip, update_type, dev=None, dstport=None): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/24 dev vxlan", f"ip addr add {new_ip}/24 dev vxlan", content, ) elif update_type == "remote": new_content = re.sub( r"dst \S+ dev vxlan", f"dst {new_ip} dev vxlan", content ) elif update_type == "dev_dstport": new_content = re.sub( r"dstport \d+ dev \S+", f"dstport {dstport} dev {dev}", content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_fdb6(name, new_ip, update_type, dev=None, dstport=None): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/64 dev vxlan", f"ip addr add {new_ip}/64 dev vxlan", content, ) elif update_type == "remote": new_content = re.sub( r"dst \S+ dev vxlan", f"dst {new_ip} dev vxlan", content ) elif update_type == "dev_dstport": new_content = re.sub( r"dstport \d+ dev \S+", f"dstport {dstport} dev {dev}", content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfile_fdb(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_vxlanfdb_iran(remote_ip, vxlan_ip, dev, dstport): lines = [ f"\033[93mTitle: Vxlan Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{vxlan_ip}\033[0m", f"\033[93mDevice: \033[97m{dev}\033[0m", f"\033[93mDestination Port: \033[97m{dstport}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_vxlanfdb_kharej(remote_ip, vxlan_ip, dev, dstport): lines = [ f"\033[93mTitle: Vxlan Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{vxlan_ip}\033[0m", f"\033[93mDevice: \033[97m{dev}\033[0m", f"\033[93mDestination Port: \033[97m{dstport}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_vxlanfdb(vxlan_ip, remote_ip, dev, dstport): current_ips = get_current_vxlan_ips_fdb() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", current_dstport], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def save_stuff_vxlanfdb6(vxlan_ip, remote_ip, dev, dstport): current_ips = get_current_vxlan_ips_fdb6() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", current_dstport], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb6("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb6("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb6( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") subprocess.run(["ip", "link", "delete", interface], check=True) script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def fdbnosec_edit_localiran(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKHAREJ\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localkharej(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localiranv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKHAREJ\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb6(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localkharejv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb6(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def vxfdb_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mVxlan \033[96m[Private IPV4]\033[0m") print("2. \033[93mVxlan \033[96m[Private IPV6]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": vxfdb_edit_localv4() break elif choice == "2": vxfdb_edit_localv6() break elif choice == "3": clear() single_edit_local() break else: print("Invalid choice.") def vxfdb_edit_localv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_local() break elif choice == "2": fdbsec_edit_local() break elif choice == "3": clear() vxfdb_edit_local() break else: print("Invalid choice.") def fdbnosec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localkharej() break elif choice == "2": fdbnosec_edit_localiran() break elif choice == "3": clear() vxfdb_edit_localv4() break else: print("Invalid choice.") def vxfdb_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localv6() break elif choice == "2": fdbsec_edit_localv6() break elif choice == "3": clear() vxfdb_edit_local() break else: print("Invalid choice.") def fdbnosec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbnosec_edit_localkharejv6() break elif choice == "2": fdbnosec_edit_localiranv6() break elif choice == "3": clear() vxfdb_edit_localv6() break else: print("Invalid choice.") def wtb_opposite_ipfdb(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def remote_ip_fdb(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"dst (\S+) dev vxlan", content) if match: return match.group(1) else: print("\033[91mno remote IP found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def vxlan_ip_fdb(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/24 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def vxlan_ip_fdb6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip addr add (\S+)/64 dev vxlan", content) if match: return match.group(1) else: print(f"\033[91mno VXLAN IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_dev_vxlan_dstport(name): try: with open(name, "r") as f: content = f.read() dev_match = re.search(r"dev (\S+)", content) dstport_match = re.search(r"dstport (\d+)", content) dev = dev_match.group(1) if dev_match else None dstport = dstport_match.group(1) if dstport_match else None return dev, dstport except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None, None def get_current_vxlan_ips_fdb(): vxlan_ip_bridge = vxlan_ip_fdb("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def get_current_vxlan_ips_fdb6(): vxlan_ip_bridge = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") return { "vxlan": vxlan_ip_bridge, } def delete_ufw_rules_fdb(ip): counterpart_ip = wtb_opposite_ipfdb(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules_fdb(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_fdb(name, new_ip, update_type, dev=None, dstport=None): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/24 dev vxlan", f"ip addr add {new_ip}/24 dev vxlan", content, ) elif update_type == "remote": new_content = re.sub( r"dst \S+ dev vxlan", f"dst {new_ip} dev vxlan", content ) elif update_type == "dev_dstport": new_content = re.sub( r"dstport \d+ dev \S+", f"dstport {dstport} dev {dev}", content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipfile_fdb6(name, new_ip, update_type, dev=None, dstport=None): try: with open(name, "r") as f: content = f.read() if update_type == "vxlan": new_content = re.sub( r"ip addr add [^ ]+/64 dev vxlan", f"ip addr add {new_ip}/64 dev vxlan", content, ) elif update_type == "remote": new_content = re.sub( r"dst \S+ dev vxlan", f"dst {new_ip} dev vxlan", content ) elif update_type == "dev_dstport": new_content = re.sub( r"dstport \d+ dev \S+", f"dstport {dstport} dev {dev}", content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_pingfile_fdb(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_vxlanfdb(vxlan_ip, remote_ip, dev, dstport): current_ips = get_current_vxlan_ips_fdb() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", "port", current_dstport], check=False, ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def save_stuff_vxlanfdb6(vxlan_ip, remote_ip, dev, dstport): current_ips = get_current_vxlan_ips_fdb6() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", "port", current_dstport], check=False, ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb6("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb6("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb6( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") subprocess.run(["ip", "link", "delete", interface], check=True) script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark("\033[92mping_v6 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v6 not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def fdbnosec_edit_localiran(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKHAREJ\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localkharej(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localiranv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKHAREJ\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb6(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbnosec_edit_localkharejv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from VXLAN file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter new Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": save_stuff_vxlanfdb6(vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") # ipsec def fdbsec_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB + IPSEC V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbsec_edit_localkharej() break elif choice == "2": fdbsec_edit_localiran() break elif choice == "3": clear() vxfdb_edit_localv4() break else: print("Invalid choice.") def fdbsec_edit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Vxlan FDB + IPSEC V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": fdbsec_edit_localkharejv6() break elif choice == "2": fdbsec_edit_localiranv6() break elif choice == "3": clear() vxfdb_edit_localv6() break else: print("Invalid choice.") def update_ipsec_conf_fdb6(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_parts = new_private_ip.split(":") if new_private_ip.endswith("::2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_fdbsec(vxlan_ip, remote_ip, dev, dstport, ipsecsecret): current_ips = get_current_vxlan_ips_fdb() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", current_dstport], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) update_ipsecsecret_fdb("/etc/ipsec.secrets", ipsecsecret) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark( "\033[92mping_vxlan service restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Service ping_vxlan not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def ipsecsecret_key_fdb(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033{0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipsecsecret_fdb(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_ipsecsecret_fdb(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def fdbsec_edit_localiran(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key_fdb("/etc/ipsec.secrets") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from Vxlan file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) display_ipsecsecret_fdb(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip update_ipsec_conf_vxsec("/etc/ipsec.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": new_secret = input( "\033[93mEnter New \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mCrazy Secret key\033[0m") elif choice == "6": save_stuff_fdbsec( vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport, ipsecsecret_key_private ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbsec_edit_localkharej(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key_fdb("/etc/ipsec.secrets") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from Vxlan file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) display_ipsecsecret_fdb(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V4 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV4\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip update_ipsec_conf_vxsec("/etc/ipsec.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": new_secret = input( "\033[93mEnter New \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mCrazy Secret key\033[0m") elif choice == "6": save_stuff_fdbsec( vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport, ipsecsecret_key_private ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def save_stuff_fdbsec6(vxlan_ip, remote_ip, dev, dstport, ipsecsecret): current_ips = get_current_vxlan_ips_fdb6() current_ip = current_ips["vxlan"] if current_ip: delete_ufw_rules_fdb(current_ip) if dstport: current_dev, current_dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") if current_dstport: try: subprocess.run( ["sudo", "ufw", "delete", "allow", current_dstport], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rule for current port: {e}\033[0m") try: subprocess.run(["sudo", "ufw", "allow", dstport], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rule for new port: {e}\033[0m") add_ufw_rules_fdb(vxlan_ip) counterpart_ip = wtb_opposite_ipfdb(vxlan_ip) try: update_pingfile_fdb("/etc/ping_vxlan.sh", counterpart_ip) update_ipfile_fdb6("/usr/local/bin/bridge.sh", vxlan_ip, update_type="vxlan") update_ipfile_fdb6("/usr/local/bin/bridge.sh", remote_ip, update_type="remote") update_ipfile_fdb6( "/usr/local/bin/bridge.sh", None, update_type="dev_dstport", dev=dev, dstport=dstport, ) update_ipsecsecret_fdb("/etc/ipsec.secrets", ipsecsecret) interface = "vxlan" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mCannot find device 'vxlan'. Proceeding...\033[0m") script = "/usr/local/bin/bridge.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "strongswan-starter"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strongswan.service"], capture_output=True, text=True, ) if "strongswan.service" in result.stdout: subprocess.run(["systemctl", "restart", "strongswan"], check=True) else: print("\033[91mstrongswan service not found. don't mind this error\033[0m") try: subprocess.run(["systemctl", "restart", "ping_vxlan"], check=True) display_checkmark( "\033[92mping_vxlan service restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Service ping_vxlan not found" in (e.stderr or ""): print("\033[91mCouldn't restart ping_vxlan\033[0m") print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m: {e}") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def fdbsec_edit_localiranv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key_fdb("/etc/ipsec.secrets") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from Vxlan file") return while True: os.system("clear") display_stuff_vxlanfdb_iran(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) display_ipsecsecret_fdb(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip update_ipsec_conf_fdb6("/etc/ipsec.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": new_secret = input( "\033[93mEnter New \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mCrazy Secret key\033[0m") elif choice == "6": save_stuff_fdbsec6( vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport, ipsecsecret_key_private ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def fdbsec_edit_localkharejv6(): remote_ip_vxlan = remote_ip_fdb("/usr/local/bin/bridge.sh") vxlan_ip_vxlan = vxlan_ip_fdb6("/usr/local/bin/bridge.sh") dev, dstport = get_dev_vxlan_dstport("/usr/local/bin/bridge.sh") ipsecsecret_key_private = ipsecsecret_key_fdb("/etc/ipsec.secrets") if not remote_ip_vxlan or not vxlan_ip_vxlan or not dev or not dstport: print("Couldn't retrieve IP addresses or device/port from Vxlan file") return while True: os.system("clear") display_stuff_vxlanfdb_kharej(remote_ip_vxlan, vxlan_ip_vxlan, dev, dstport) display_ipsecsecret_fdb(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mVXLAN FDB V6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN\033[93m Public IP\033[0m") print("2. \033[93mChange \033[97mVxlan\033[93m Private IPV6\033[0m") print("3. \033[93mChange \033[97mDevice name\033[0m") print("4. \033[93mChange \033[97mDestination Port\033[0m") print("5. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[VXLAN]\033[93m :\033[0m " ) if new_ip: vxlan_ip_vxlan = new_ip update_ipsec_conf_fdb6("/etc/ipsec.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_vxlan = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": dev = input("\033[93mEnter new device (e.g: eth0) :\033[0m ") elif choice == "4": dstport = input("\033[93mEnter new destination port :\033[0m ") elif choice == "5": new_secret = input( "\033[93mEnter New \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mCrazy Secret key\033[0m") elif choice == "6": save_stuff_fdbsec6( vxlan_ip_vxlan, remote_ip_vxlan, dev, dstport, ipsecsecret_key_private ) update_ipsec_ip(vxlan_ip_vxlan) break elif choice == "0": clear() single_edit_local() break else: print("Please select a valid option.") def multi_edit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m6TO4\033[93m[Sit]\033[0m") print("2. \033[93mIP6IP6\033[0m") print("3. \033[92mGRE6\033[0m") print("4. \033[93mGRE6TAP IPV4\033[0m") print("5. \033[92mGeneve UDP \033[0m") print("6. \033[93mGeneve + GRE6 [IPV4]\033[0m") print("7. \033[93mWireguard\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": private_multiedit_local() break elif choice == "2": ip6ip6_multiedit_local() break elif choice == "3": gre6_multiedit_local() break elif choice == "4": gre6tap_multiedit_local() break elif choice == "5": gen_multiedit_localmenu() break elif choice == "6": gengre_multiedit_local() break elif choice == "7": wireguard_edit_server() break elif choice == "0": clear() edit_local() break else: print("Invalid choice.") def private_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatenosec_multiedit_local() break elif choice == "2": privatesec_multiedit_local() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") def privatenosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatenosec_edit_localkharej_multi() break elif choice == "2": privatenosec_edit_localiran_multi() break elif choice == "3": clear() private_multiedit_local() break else: print("Invalid choice.") def privatenosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iranfive1_editmulti_local() break elif server_type == "2": iranfive2_editmulti_local() break elif server_type == "3": iranfive3_editmulti_local() break elif server_type == "4": iranfive4_editmulti_local() break elif server_type == "5": iranfive5_editmulti_local() break elif server_type == "6": kharejone_editmulti_localmenu() break elif server_type == "0": os.system("clear") privatenosec_multiedit_local() break else: print("Invalid choice.") def kharejone_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejone1_editmulti_local() break elif server_type == "2": kharejone2_editmulti_local() break elif server_type == "3": kharejone3_editmulti_local() break elif server_type == "4": kharejone4_editmulti_local() break elif server_type == "5": kharejone5_editmulti_local() break elif server_type == "0": os.system("clear") privatenosec_multiedit_local() break else: print("Invalid choice.") def privatenosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_editmulti_local() break elif server_type == "2": kharej2_editmulti_local() break elif server_type == "3": kharej3_editmulti_local() break elif server_type == "4": kharej4_editmulti_local() break elif server_type == "5": kharej5_editmulti_local() break elif server_type == "6": kharej6_editmulti_local() break elif server_type == "7": kharej7_editmulti_local() break elif server_type == "8": kharej8_editmulti_local() break elif server_type == "9": kharej9_editmulti_local() break elif server_type == "10": kharej10_editmulti_local() break elif server_type == "11": iran_editmulti_local() break elif server_type == "0": os.system("clear") privatenosec_multiedit_local() break else: print("Invalid choice.") def iran_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ir1_editmulti_local() break elif server_type == "2": ir2_editmulti_local() break elif server_type == "3": ir3_editmulti_local() break elif server_type == "4": ir4_editmulti_local() break elif server_type == "5": ir5_editmulti_local() break elif server_type == "6": ir6_editmulti_local() break elif server_type == "7": ir7_editmulti_local() break elif server_type == "8": ir8_editmulti_local() break elif server_type == "9": ir9_editmulti_local() break elif server_type == "10": ir10_editmulti_local() break elif server_type == "0": os.system("clear") privatenosec_multiedit_local() break else: print("Invalid choice.") # private 1 def clear(): subprocess.run(["clear"]) def delete_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_pingfile_sit(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def add_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_checkmark(message): print("\u2714 " + message) # different stuff def display_stuff_privateiran1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[1]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[1]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip1(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi?", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips1(): private_ip_private = private_ip1("/etc/private1.sh") return { "private": private_ip_private, } def update_ipfile_sit1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi1", f"ip -6 addr add {new_ip}/64 dev azumi1", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi1", f"ip -6 route add {counterpart_ip}/64 dev azumi1", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit1(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips1() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_sit1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_sit1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_sit1("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumi1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v61"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[1]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [1]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 2 def display_stuff_privateiran2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[2]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[2]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip2(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi2", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips2(): private_ip_private = private_ip2("/etc/private2.sh") return { "private": private_ip_private, } def update_ipfile_sit2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi2", f"ip -6 addr add {new_ip}/64 dev azumi2", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi2", f"ip -6 route add {counterpart_ip}/64 dev azumi2", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit2(private_ip, local_ip, remote_ip): try: current_ips = get_current_private_ips2() current_ip = current_ips.get("private") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_sit2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_sit2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_sit2("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumi2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91mError bringing interface down or deleting it\033[0m") raise script = "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v62"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91mError applying network stuff\033[0m") except Exception as e: print(f"\033[91mOut of ordinary error: {e}\033[0m") def ir2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[2]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [2]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 3 def display_stuff_privateiran3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[3]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[3]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip3(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi3", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips3(): private_ip_private = private_ip3("/etc/private3.sh") return { "private": private_ip_private, } def update_ipfile_sit3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi3", f"ip -6 addr add {new_ip}/64 dev azumi3", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi3", f"ip -6 route add {counterpart_ip}/64 dev azumi3", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit3(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips3() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_sit3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_sit3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_sit3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumi3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v63"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[3]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 4 def display_stuff_privateiran4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[4]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[4]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip4(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi4", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips4(): private_ip_private = private_ip4("/etc/private4.sh") return { "private": private_ip_private, } def update_ipfile_sit4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi4", f"ip -6 addr add {new_ip}/64 dev azumi4", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi4", f"ip -6 route add {counterpart_ip}/64 dev azumi4", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit4(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips4() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_sit4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_sit4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_sit4("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumi4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v64"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[4]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [4]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 5 def display_stuff_privateiran5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[5]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[5]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip5(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi5", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips5(): private_ip_private = private_ip5("/etc/private5.sh") return { "private": private_ip_private, } def update_ipfile_sit5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi5", f"ip -6 addr add {new_ip}/64 dev azumi5", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi5", f"ip -6 route add {counterpart_ip}/64 dev azumi5", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit5(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips5() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_sit5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_sit5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_sit5("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumi5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v65"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[5]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [5]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 6 def display_stuff_privateiran6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[6]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[6]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip6(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi6", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips6(): private_ip_private = private_ip6("/etc/private6.sh") return { "private": private_ip_private, } def update_ipfile_sit6(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi6", f"ip -6 addr add {new_ip}/64 dev azumi6", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi6", f"ip -6 route add {counterpart_ip}/64 dev azumi6", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit6(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips6() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v66.sh", counterpart_ip) update_ipfile_sit6("/etc/private6.sh", private_ip, update_type="private") update_ipfile_sit6("/etc/private6.sh", local_ip, update_type="local") update_ipfile_sit6("/etc/private6.sh", remote_ip, update_type="remote") interface = "azumi6" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private6.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v66"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip6("/etc/private6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran6( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[6]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [6]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [6]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit6(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip6("/etc/private6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej6( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [6] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [6]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit6(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 7 def display_stuff_privateiran7(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[7]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej7(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[7]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip7(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi7", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips7(): private_ip_private = private_ip7("/etc/private7.sh") return { "private": private_ip_private, } def update_ipfile_sit7(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi7", f"ip -6 addr add {new_ip}/64 dev azumi7", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi7", f"ip -6 route add {counterpart_ip}/64 dev azumi7", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit7(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips7() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v67.sh", counterpart_ip) update_ipfile_sit7("/etc/private7.sh", private_ip, update_type="private") update_ipfile_sit7("/etc/private7.sh", local_ip, update_type="local") update_ipfile_sit7("/etc/private7.sh", remote_ip, update_type="remote") interface = "azumi7" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private7.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v67"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip7("/etc/private7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran7( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[7]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [7]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [7]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit7(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip7("/etc/private7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej7( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [7] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [7]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit7(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 8 def display_stuff_privateiran8(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[8]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej8(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[8]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip8(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi8", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips8(): private_ip_private = private_ip8("/etc/private8.sh") return { "private": private_ip_private, } def update_ipfile_sit8(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi8", f"ip -6 addr add {new_ip}/64 dev azumi8", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi8", f"ip -6 route add {counterpart_ip}/64 dev azumi8", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit8(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips8() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v68.sh", counterpart_ip) update_ipfile_sit8("/etc/private8.sh", private_ip, update_type="private") update_ipfile_sit8("/etc/private8.sh", local_ip, update_type="local") update_ipfile_sit8("/etc/private8.sh", remote_ip, update_type="remote") interface = "azumi8" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private8.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v68"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip8("/etc/private8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran8( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[8]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [8]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [8]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit8(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip8("/etc/private8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej8( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [8] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [8]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit8(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 9 def display_stuff_privateiran9(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[9]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej9(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[9]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip9(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi9", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips9(): private_ip_private = private_ip9("/etc/private9.sh") return { "private": private_ip_private, } def update_ipfile_sit9(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi9", f"ip -6 addr add {new_ip}/64 dev azumi9", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi9", f"ip -6 route add {counterpart_ip}/64 dev azumi9", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit9(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips9() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v69.sh", counterpart_ip) update_ipfile_sit9("/etc/private9.sh", private_ip, update_type="private") update_ipfile_sit9("/etc/private9.sh", local_ip, update_type="local") update_ipfile_sit9("/etc/private9.sh", remote_ip, update_type="remote") interface = "azumi9" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private9.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v69"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip9("/etc/private9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran9( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[9]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [9]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [9]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit9(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip9("/etc/private9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej9( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [9] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [9]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit9(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # privateip 10 def display_stuff_privateiran10(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej \033[96m[10]\033[92m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharej10(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej \033[96m[10]\033[92m Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def private_ip10(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumi10", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ips10(): private_ip_private = private_ip10("/etc/private10.sh") return { "private": private_ip_private, } def update_ipfile_sit10(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi10", f"ip -6 addr add {new_ip}/64 dev azumi10", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi10", f"ip -6 route add {counterpart_ip}/64 dev azumi10", new_content, ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sit10(private_ip, local_ip, remote_ip): current_ips = get_current_private_ips10() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v610.sh", counterpart_ip) update_ipfile_sit10("/etc/private10.sh", private_ip, update_type="private") update_ipfile_sit10("/etc/private10.sh", local_ip, update_type="local") update_ipfile_sit10("/etc/private10.sh", remote_ip, update_type="remote") interface = "azumi10" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/private10.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v610"], check=True) display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip10("/etc/private10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiran10( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN - \033[96mServer[10]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [10]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [10]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit10(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip10("/etc/private10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharej10( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej [10] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [10]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit10(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def display_stuff_privateiranfive1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[1]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone1(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[1]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privateiranfive2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[2]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone2(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[2]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privateiranfive3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[3]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone3(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[3]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privateiranfive4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[4]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone4(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[4]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privateiranfive5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[5]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone5(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[5]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def kharejone1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej - \033[96mServer[1]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit1(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej - \033[96mServer[2]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit2(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej - \033[96mServer[3]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit3(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej - \033[96mServer[4]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit4(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate[SIT]\033[93m Kharej - \033[96mServer[5]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate[SIT]\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": save_stuff_sit5(private_ip_private, local_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # ipsec def privatesec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Private + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": privatesec_edit_localkharej_multi() break elif choice == "2": privatesec_edit_localiran_multi() break elif choice == "3": clear() private_multiedit_local() break else: print("Invalid choice.") def privatesec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iranfive1sec_editmulti_local() break elif server_type == "2": iranfive2sec_editmulti_local() break elif server_type == "3": iranfive3sec_editmulti_local() break elif server_type == "4": iranfive4sec_editmulti_local() break elif server_type == "5": iranfive5sec_editmulti_local() break elif server_type == "6": kharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") privatesec_multiedit_local() break else: print("Invalid choice.") def kharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejone1sec_editmulti_local() break elif server_type == "2": kharejone2sec_editmulti_local() break elif server_type == "3": kharejone3sec_editmulti_local() break elif server_type == "4": kharejone4sec_editmulti_local() break elif server_type == "5": kharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") privatesec_multiedit_local() break else: print("Invalid choice.") def privatesec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1sec_editmulti_local() break elif server_type == "2": kharej2sec_editmulti_local() break elif server_type == "3": kharej3sec_editmulti_local() break elif server_type == "4": kharej4sec_editmulti_local() break elif server_type == "5": kharej5sec_editmulti_local() break elif server_type == "6": iransec_editmulti_local() break elif server_type == "0": os.system("clear") privatesec_multiedit_local() break else: print("Invalid choice.") def iransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ir1sec_editmulti_local() break elif server_type == "2": ir2sec_editmulti_local() break elif server_type == "3": ir3sec_editmulti_local() break elif server_type == "4": ir4sec_editmulti_local() break elif server_type == "5": ir5sec_editmulti_local() break elif server_type == "0": os.system("clear") privatesec_multiedit_local() break else: print("Invalid choice.") # private ipsec predefined def ipsecsecret_key(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(\S+)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipsecsecret(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_conf_sitv6(name, new_private_ip): try: with open(name, "r") as f: content = f.read() ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", new_content) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_ipsecsecret(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_ip(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] for line in lines: if ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) # changes starts from here 1 # iran ipsec conf def update_ipsec_conf_iran1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn private1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn private1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn private1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_kharej1(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips1() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_sit1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_sit1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_sit1("/etc/private1.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec1.conf", private_ip) interface = "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v61"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_iran1(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips1() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_sit1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_sit1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_sit1("/etc/private1.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_iran1("/etc/ipsec1.conf", private_ip) interface = "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v61"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_ip_multi(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] modified = False for line in lines: if not modified and ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") modified = True else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def ir1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN - \033[96mServer [1]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [1]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran1( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP:\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej1( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes starts from here 2 # iran ipsec conf def update_ipsec_conf_iran2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn private2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn private2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn private2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_kharej2(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips2() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_sit2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_sit2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_sit2("/etc/private2.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec1.conf", private_ip) interface = "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v62"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_iran2(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips2() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_sit2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_sit2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_sit2("/etc/private2.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_iran2("/etc/ipsec1.conf", private_ip) interface = "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v62"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_ip_multi2(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 2: raise ValueError("The secrets file doesn't have at least 2 lines") new_lines = [] for index, line in enumerate(lines): if index == 1 and ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi3(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 3: raise ValueError("The secrets file doesn't have at least 3 lines") new_lines = [] for index, line in enumerate(lines): if index == 2: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi4(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 4: raise ValueError("The secrets file doesn't have at least 4 lines") new_lines = [] for index, line in enumerate(lines): if index == 3: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def update_ipsec_ip_multi5(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() if len(lines) < 5: raise ValueError("The secrets file doesn't have at least 5 lines") new_lines = [] for index, line in enumerate(lines): if index == 4: parts = line.split() if len(parts) >= 3 and parts[2] == ":": new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def ir2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN - \033[96mServer [2]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [2]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran2( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP:\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej2( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes starts from here 3 # iran ipsec conf def update_ipsec_conf_iran3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn private3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn private3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn private3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_kharej3(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips3() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_sit1("/etc/private3.sh", private_ip, update_type="private") update_ipfile_sit1("/etc/private3.sh", local_ip, update_type="local") update_ipfile_sit1("/etc/private3.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec1.conf", private_ip) interface = "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v63"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_iran3(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips3() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_sit3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_sit3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_sit3("/etc/private3.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_iran3("/etc/ipsec1.conf", private_ip) interface = "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v63"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN - \033[96mServer [3]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran3( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP:\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej3( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes starts from here 4 # iran ipsec conf def update_ipsec_conf_iran4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn private4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn private4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn private4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_kharej4(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips4() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_sit4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_sit4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_sit4("/etc/private4.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec1.conf", private_ip) interface = "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v64"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_iran4(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips4() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_sit4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_sit4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_sit4("/etc/private4.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_iran1("/etc/ipsec1.conf", private_ip) interface = "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v64"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN - \033[96mServer [4]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [4]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran4( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP:\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej4( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes starts from here 5 # iran ipsec conf def update_ipsec_conf_iran5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn private5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn private5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn private5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_kharej5(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips5() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_sit5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_sit5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_sit5("/etc/private5.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_sitv6("/etc/ipsec1.conf", private_ip) interface = "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v65"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_sitsec_iran5(private_ip, local_ip, remote_ip, ipsecsecret): current_ips = get_current_private_ips5() current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_sit5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_sit5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_sit5("/etc/private5.sh", remote_ip, update_type="remote") update_ipsecsecret("/etc/ipsec.secrets", ipsecsecret) update_ipsec_conf_iran1("/etc/ipsec1.conf", private_ip) interface = "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") try: script = "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("Network interface already exists, don't mind this") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "restart", "ping_v65"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print( "\033[91mstrong-azumi service not found. don't mind this error\033[0m" ) display_checkmark( f"\033[92mChanges saved and {interface} interface & IPSEC updated successfully!\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff - privateipsec\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ir5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN - \033[96mServer [5]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [5]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKHAREJ [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran5( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharej5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP:\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej5( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # fiveiran one kharej def kharejone1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej - \033[96mServer [1]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[96m[1]\033[93m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran1( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej1( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej - \033[96mServer [2]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[96m[2]\033[93m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran2( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip2("/etc/private2.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej2( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej - \033[96mServer [3]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[96m[3]\033[93m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran3( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip3("/etc/private3.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej3( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej - \033[96mServer [4]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[96m[4]\033[93m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran4( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip4("/etc/private4.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej4( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def kharejone5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mPrivate + IPSEC\033[93m Kharej - \033[96mServer [5]\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[96m[5]\033[93m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_iran5( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def iranfive5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip5("/etc/private5.sh") ipsecsecret_key_private = ipsecsecret_key("/etc/ipsec.secrets") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not ipsecsecret_key_private ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_ipsecsecret(ipsecsecret_key_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mPrivate + IPSEC\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IP \033[0m") print("4. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[96mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP:\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_secret = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_secret: ipsecsecret_key_private = new_secret else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_sitsec_kharej5( private_ip_private, local_ip_private, remote_ip_private, ipsecsecret_key_private, ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # ipip ipsec def ip6ip6_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ip6ip6nosec_multiedit_local() break elif choice == "2": ip6ip6sec_multiedit_local() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") # ipsec menu def ip6ip6sec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ip6ip6sec_edit_localkharej_multi() break elif choice == "2": ip6ip6sec_edit_localiran_multi() break elif choice == "3": clear() ip6ip6_multiedit_local() break else: print("Invalid choice.") def ip6ip6sec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipiranfive1sec_editmulti_local() break elif server_type == "2": ipipiranfive2sec_editmulti_local() break elif server_type == "3": ipipiranfive3sec_editmulti_local() break elif server_type == "4": ipipiranfive4sec_editmulti_local() break elif server_type == "5": ipipiranfive5sec_editmulti_local() break elif server_type == "6": ipipkharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") ip6ip6sec_multiedit_local() break else: print("Invalid choice.") def ipipkharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipkharejone1sec_editmulti_local() break elif server_type == "2": ipipkharejone2sec_editmulti_local() break elif server_type == "3": ipipkharejone3sec_editmulti_local() break elif server_type == "4": ipipkharejone4sec_editmulti_local() break elif server_type == "5": ipipkharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6sec_multiedit_local() break else: print("Invalid choice.") def ip6ip6sec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipkharej1sec_editmulti_local() break elif server_type == "2": ipipkharej2sec_editmulti_local() break elif server_type == "3": ipipkharej3sec_editmulti_local() break elif server_type == "4": ipipkharej4sec_editmulti_local() break elif server_type == "5": ipipkharej5sec_editmulti_local() break elif server_type == "6": ipipiransec_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6sec_multiedit_local() break else: print("Invalid choice.") def ipipiransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipir1sec_editmulti_local() break elif server_type == "2": ipipir2sec_editmulti_local() break elif server_type == "3": ipipir3sec_editmulti_local() break elif server_type == "4": ipipir4sec_editmulti_local() break elif server_type == "5": ipipir5sec_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6sec_multiedit_local() break else: print("Invalid choice.") def local_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"local (\S+)", content) if match: return match.group(1) else: print(f"\033[91mno local IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def remote_ip(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"remote (\S+)", content) if match: return match.group(1) else: print("\033[91mno remote IP found \033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def delete_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip], check=False) subprocess.run( ["sudo", "ufw", "delete", "allow", "from", counterpart_ip], check=False, ) except subprocess.CalledProcessError as e: print(f"\033[91merror deleting UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def add_ufw_rules(ip): counterpart_ip = wtb_opposite_ip(ip) try: subprocess.run(["sudo", "ufw", "allow", "from", ip], check=True) subprocess.run(["sudo", "ufw", "allow", "from", counterpart_ip], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror adding UFW rules: {e}\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def update_pingfile(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_ip6ip6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: IP6IP6 Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def get_ipsecsecret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "(.*)"', content) if match: return match.group(1) else: print("\033[91mno IPsec key found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipsecsecret(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "\S+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_ip(new_vxlan_ip): def opposite_ip(ip): if ":" in ip: parts = ip.split(":") if parts[-1].endswith("1"): parts[-1] = parts[-1][:-1] + "2" else: parts[-1] = parts[-1][:-1] + "1" return ":".join(parts) else: octets = ip.split(".") if octets[-1] == "1": octets[-1] = "2" else: octets[-1] = "1" return ".".join(octets) secrets_file = "/etc/ipsec.secrets" opposite_ip_addr = opposite_ip(new_vxlan_ip) with open(secrets_file, "r") as file: lines = file.readlines() new_lines = [] for line in lines: if ": PSK" in line: parts = line.split() if len(parts) > 2: new_line = ( f'{opposite_ip_addr} {new_vxlan_ip} : PSK "{parts[-1][1:-1]}"' ) new_lines.append(new_line + "\n") else: new_lines.append(line) else: new_lines.append(line) with open(secrets_file, "w") as file: file.writelines(new_lines) def display_checkmark(message): print("\u2714 " + message) def display_ipsecsecret(secret_key): box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") print(f"\033[93m Title: \033[93m IPsec Secret Key\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") # changes def update_ipfile_ipip1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip1("/etc/ipip1.sh", new_ip, update_type="ipip_local") update_ipfile_ipip1( "/etc/ipip1.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def private_ipip1(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip (-6 )?addr add (\S+)/64 dev azumip?", content) if match: return match.group(2) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def get_current_private_ipsipip1(): private_ip_private = private_ipip1("/etc/private1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck1(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip1() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_ipip1("/etc/ipip1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/ipip1.sh", remote_ip, update_type="remote") update_ipfile_ipip1("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_ipip1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_ipip1("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumip1" if is_ipip else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip1.sh" if is_ipip else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def save_stuff_ipipseciran1(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip1() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_ipip1("/etc/ipip1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/ipip1.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip1("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_ipip1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_ipip1("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumip1" if is_ipip else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip1.sh" if is_ipip else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip1("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [1]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip1("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes2 def update_ipfile_ipip2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip2("/etc/ipip2.sh", new_ip, update_type="ipip_local") update_ipfile_ipip2( "/etc/ipip2.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip2(): private_ip_private = private_ipip1("/etc/private2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck2(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip2() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_ipip2("/etc/ipip2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/ipip2.sh", remote_ip, update_type="remote") update_ipfile_ipip2("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_ipip2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_ipip2("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumip2" if is_ipip else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip2.sh" if is_ipip else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def save_stuff_ipipseciran2(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip2() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_ipip2("/etc/ipip2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/ipip2.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip2("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_ipip2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_ipip2("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumip2" if is_ipip else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip2.sh" if is_ipip else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip2("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [2]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip2("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi2(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes 3 def update_ipfile_ipip3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip3("/etc/ipip3.sh", new_ip, update_type="ipip_local") update_ipfile_ipip3( "/etc/ipip3.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip3(): private_ip_private = private_ipip1("/etc/private3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck3(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip3() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_ipip3("/etc/ipip3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/ipip3.sh", remote_ip, update_type="remote") update_ipfile_ipip3("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_ipip3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_ipip3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumip3" if is_ipip else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip3.sh" if is_ipip else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipipseciran3(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip3() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_ipip3("/etc/ipip3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/ipip3.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip3("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_ipip3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_ipip3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumip3" if is_ipip else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip3.sh" if is_ipip else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def ipipkharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip3("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip3("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi3(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes 3 def update_ipfile_ipip3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip3("/etc/ipip3.sh", new_ip, update_type="ipip_local") update_ipfile_ipip3( "/etc/ipip3.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip3(): private_ip_private = private_ipip1("/etc/private3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck3(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip3() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_ipip3("/etc/ipip3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/ipip3.sh", remote_ip, update_type="remote") update_ipfile_ipip3("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_ipip3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_ipip3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumip3" if is_ipip else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip3.sh" if is_ipip else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipipseciran3(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip3() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_ipip3("/etc/ipip3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/ipip3.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip3("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_ipip3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_ipip3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumip3" if is_ipip else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip3.sh" if is_ipip else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def ipipkharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip3("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip3("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi3(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes 4 def update_ipfile_ipip4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip4("/etc/ipip4.sh", new_ip, update_type="ipip_local") update_ipfile_ipip4( "/etc/ipip4.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip4(): private_ip_private = private_ipip1("/etc/private4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck4(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip4() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_ipip4("/etc/ipip4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/ipip4.sh", remote_ip, update_type="remote") update_ipfile_ipip4("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_ipip4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_ipip4("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumip4" if is_ipip else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip4.sh" if is_ipip else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipipseciran4(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip4() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_ipip4("/etc/ipip4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/ipip4.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip4("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_ipip4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_ipip4("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumip4" if is_ipip else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip4.sh" if is_ipip else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def ipipkharej4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip4("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [4]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip4("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi4(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes 5 def update_ipfile_ipip5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip5("/etc/ipip5.sh", new_ip, update_type="ipip_local") update_ipfile_ipip5( "/etc/ipip5.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsipip5(): private_ip_private = private_ipip1("/etc/private5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def save_stuff_ipipseck5(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip5() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_ipip5("/etc/ipip5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/ipip5.sh", remote_ip, update_type="remote") update_ipfile_ipip5("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_ipip5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_ipip5("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumip5" if is_ipip else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip5.sh" if is_ipip else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_iranipip5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn ipip5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn ipip5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn ipip5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipipseciran5(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip5() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_ipip5("/etc/ipip5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/ipip5.sh", remote_ip, update_type="remote") update_ipsec_conf_iranipip5("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_ipip5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_ipip5("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumip5" if is_ipip else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip5.sh" if is_ipip else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrong service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: IPIP + IPSEC error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def ipipkharej5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip5("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipir5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [5]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip5("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi5(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # kharej one iran 5 ipipsec def ipipiranfive1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip1("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipkharejone1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip1("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipiranfive2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip2("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipkharejone2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip2("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi2(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 3 def ipipiranfive3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip3("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipkharejone3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip3("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi3(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 4 def ipipiranfive4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip4("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipkharejone4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip4("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi4(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 5 def ipipiranfive5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipfile_ipip5("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseck5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseck5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipipkharejone5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_ipip private_ip_ipip = new_ip update_ipsec_conf_iranipip5("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_ipipseciran5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipipseciran5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) update_ipsec_ip_multi5(private_ip_ipip) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ip6ip6nosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m IP6IP6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[10] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": ip6ip6nosec_edit_localkharej_multi() break elif choice == "2": ip6ip6nosec_edit_localiran_multi() break elif choice == "3": clear() ip6ip6_multiedit_local() break else: print("Invalid choice.") def ip6ip6nosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipiranfive1_editmulti_local() break elif server_type == "2": ipipiranfive2_editmulti_local() break elif server_type == "3": ipipiranfive3_editmulti_local() break elif server_type == "4": ipipiranfive4_editmulti_local() break elif server_type == "5": ipipiranfive5_editmulti_local() break elif server_type == "6": ipipiranfive6_editmulti_local() break elif server_type == "7": ipipiranfive7_editmulti_local() break elif server_type == "8": ipipiranfive8_editmulti_local() break elif server_type == "9": ipipiranfive9_editmulti_local() break elif server_type == "10": ipipiranfive10_editmulti_local() break elif server_type == "11": ipipkharejone_editmulti_localmenu() break elif server_type == "0": os.system("clear") ip6ip6nosec_multiedit_local() break else: print("Invalid choice.") def ipipkharejone_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej Menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipkharejone1_editmulti_local() break elif server_type == "2": ipipkharejone2_editmulti_local() break elif server_type == "3": ipipkharejone3_editmulti_local() break elif server_type == "4": ipipkharejone4_editmulti_local() break elif server_type == "5": ipipkharejone5_editmulti_local() break elif server_type == "6": ipipkharejone6_editmulti_local() break elif server_type == "7": ipipkharejone7_editmulti_local() break elif server_type == "8": ipipkharejone8_editmulti_local() break elif server_type == "9": ipipkharejone9_editmulti_local() break elif server_type == "10": ipipkharejone10_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6nosec_multiedit_local() break else: print("Invalid choice.") def ip6ip6nosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipkharej1_editmulti_local() break elif server_type == "2": ipipkharej2_editmulti_local() break elif server_type == "3": ipipkharej3_editmulti_local() break elif server_type == "4": ipipkharej4_editmulti_local() break elif server_type == "5": ipipkharej5_editmulti_local() break elif server_type == "6": ipipkharej6_editmulti_local() break elif server_type == "7": ipipkharej7_editmulti_local() break elif server_type == "8": ipipkharej8_editmulti_local() break elif server_type == "9": ipipkharej9_editmulti_local() break elif server_type == "10": ipipkharej10_editmulti_local() break elif server_type == "11": ipipiran_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6nosec_multiedit_local() break else: print("Invalid choice.") def ipipiran_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipipir1_editmulti_local() break elif server_type == "2": ipipir2_editmulti_local() break elif server_type == "3": ipipir3_editmulti_local() break elif server_type == "4": ipipir4_editmulti_local() break elif server_type == "5": ipipir5_editmulti_local() break elif server_type == "6": ipipir6_editmulti_local() break elif server_type == "7": ipipir7_editmulti_local() break elif server_type == "8": ipipir8_editmulti_local() break elif server_type == "9": ipipir9_editmulti_local() break elif server_type == "10": ipipir10_editmulti_local() break elif server_type == "0": os.system("clear") ip6ip6nosec_multiedit_local() break else: print("Invalid choice.") def save_stuff_ipip1(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip1() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_ipip1("/etc/ipip1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/ipip1.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_ipip1("/etc/private1.sh", private_ip, update_type="private") update_ipfile_ipip1("/etc/private1.sh", local_ip, update_type="local") update_ipfile_ipip1("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumip1" if is_ipip else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip1.sh" if is_ipip else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 2 def save_stuff_ipip2(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip2() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_ipip2("/etc/ipip2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/ipip2.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_ipip2("/etc/private2.sh", private_ip, update_type="private") update_ipfile_ipip2("/etc/private2.sh", local_ip, update_type="local") update_ipfile_ipip2("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumip2" if is_ipip else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip2.sh" if is_ipip else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 3 def save_stuff_ipip3(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip3() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_ipip3("/etc/ipip3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/ipip3.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_ipip3("/etc/private3.sh", private_ip, update_type="private") update_ipfile_ipip3("/etc/private3.sh", local_ip, update_type="local") update_ipfile_ipip3("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumip3" if is_ipip else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip3.sh" if is_ipip else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 4 def save_stuff_ipip4(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip4() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_ipip4("/etc/ipip4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/ipip4.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_ipip4("/etc/private4.sh", private_ip, update_type="private") update_ipfile_ipip4("/etc/private4.sh", local_ip, update_type="local") update_ipfile_ipip4("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumip4" if is_ipip else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip4.sh" if is_ipip else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 5 def save_stuff_ipip5(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip5() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_ipip5("/etc/ipip5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/ipip5.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_ipip5("/etc/private5.sh", private_ip, update_type="private") update_ipfile_ipip5("/etc/private5.sh", local_ip, update_type="local") update_ipfile_ipip5("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumip5" if is_ipip else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip5.sh" if is_ipip else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 6 def get_current_private_ipsipip6(): private_ip_private = private_ipip1("/etc/private6.sh") private_ip_ipip = private_ipip1("/etc/ipip6.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def update_ipfile_ipip6(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip6("/etc/ipip6.sh", new_ip, update_type="ipip_local") update_ipfile_ipip6( "/etc/ipip6.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipip6(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip6() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip6.sh", counterpart_ip) update_ipfile_ipip6("/etc/ipip6.sh", private_ip, update_type="private") update_ipfile_ipip6("/etc/ipip6.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v66.sh", counterpart_ip) update_ipfile_ipip6("/etc/private6.sh", private_ip, update_type="private") update_ipfile_ipip6("/etc/private6.sh", local_ip, update_type="local") update_ipfile_ipip6("/etc/private6.sh", remote_ip, update_type="remote") interface = "azumip6" if is_ipip else "azumi6" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip6.sh" if is_ipip else "/etc/private6.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v66"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip6"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_ipip = local_ip("/etc/ipip6.sh") remote_ip_ipip = remote_ip("/etc/ipip6.sh") private_ip_ipip = private_ipip1("/etc/ipip6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [6] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [6] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip6( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip6( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_ipip = local_ip("/etc/ipip6.sh") remote_ip_ipip = remote_ip("/etc/ipip6.sh") private_ip_ipip = private_ipip1("/etc/ipip6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [6] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip6( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip6( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 7 def get_current_private_ipsipip7(): private_ip_private = private_ipip1("/etc/private7.sh") private_ip_ipip = private_ipip1("/etc/ipip7.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def update_ipfile_ipip7(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip7("/etc/ipip7.sh", new_ip, update_type="ipip_local") update_ipfile_ipip7( "/etc/ipip7.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipip7(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip7() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip7.sh", counterpart_ip) update_ipfile_ipip7("/etc/ipip7.sh", private_ip, update_type="private") update_ipfile_ipip7("/etc/ipip7.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v67.sh", counterpart_ip) update_ipfile_ipip7("/etc/private7.sh", private_ip, update_type="private") update_ipfile_ipip7("/etc/private7.sh", local_ip, update_type="local") update_ipfile_ipip7("/etc/private7.sh", remote_ip, update_type="remote") interface = "azumip7" if is_ipip else "azumi7" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip7.sh" if is_ipip else "/etc/private7.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v67"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip7"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_ipip = local_ip("/etc/ipip7.sh") remote_ip_ipip = remote_ip("/etc/ipip7.sh") private_ip_ipip = private_ipip1("/etc/ipip7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [7] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [7] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip7( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip7( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_ipip = local_ip("/etc/ipip7.sh") remote_ip_ipip = remote_ip("/etc/ipip7.sh") private_ip_ipip = private_ipip1("/etc/ipip7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [7] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip7( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip7( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 8 def get_current_private_ipsipip8(): private_ip_private = private_ipip1("/etc/private8.sh") private_ip_ipip = private_ipip1("/etc/ipip8.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def update_ipfile_ipip8(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip8("/etc/ipip8.sh", new_ip, update_type="ipip_local") update_ipfile_ipip8( "/etc/ipip8.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipip8(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip8() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip8.sh", counterpart_ip) update_ipfile_ipip8("/etc/ipip8.sh", private_ip, update_type="private") update_ipfile_ipip8("/etc/ipip8.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v68.sh", counterpart_ip) update_ipfile_ipip8("/etc/private8.sh", private_ip, update_type="private") update_ipfile_ipip8("/etc/private8.sh", local_ip, update_type="local") update_ipfile_ipip8("/etc/private8.sh", remote_ip, update_type="remote") interface = "azumip8" if is_ipip else "azumi8" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip8.sh" if is_ipip else "/etc/private8.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v68"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip8"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_ipip = local_ip("/etc/ipip8.sh") remote_ip_ipip = remote_ip("/etc/ipip8.sh") private_ip_ipip = private_ipip1("/etc/ipip8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [8] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [8] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip8( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip8( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_ipip = local_ip("/etc/ipip8.sh") remote_ip_ipip = remote_ip("/etc/ipip8.sh") private_ip_ipip = private_ipip1("/etc/ipip8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [8] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip8( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip8( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 9 def get_current_private_ipsipip9(): private_ip_private = private_ipip1("/etc/private9.sh") private_ip_ipip = private_ipip1("/etc/ipip9.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def update_ipfile_ipip9(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip9("/etc/ipip9.sh", new_ip, update_type="ipip_local") update_ipfile_ipip9( "/etc/ipip9.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipip9(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip9() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip9.sh", counterpart_ip) update_ipfile_ipip9("/etc/ipip9.sh", private_ip, update_type="private") update_ipfile_ipip9("/etc/ipip9.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v69.sh", counterpart_ip) update_ipfile_ipip9("/etc/private9.sh", private_ip, update_type="private") update_ipfile_ipip9("/etc/private9.sh", local_ip, update_type="local") update_ipfile_ipip9("/etc/private9.sh", remote_ip, update_type="remote") interface = "azumip9" if is_ipip else "azumi9" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip9.sh" if is_ipip else "/etc/private9.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v69"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip9"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_ipip = local_ip("/etc/ipip9.sh") remote_ip_ipip = remote_ip("/etc/ipip9.sh") private_ip_ipip = private_ipip1("/etc/ipip9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [9] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [9] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip9( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip9( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_ipip = local_ip("/etc/ipip9.sh") remote_ip_ipip = remote_ip("/etc/ipip9.sh") private_ip_ipip = private_ipip1("/etc/ipip9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [9] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip9( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip9( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 10 def get_current_private_ipsipip10(): private_ip_private = private_ipip1("/etc/private10.sh") private_ip_ipip = private_ipip1("/etc/ipip10.sh") return { "private": private_ip_private, "ipip": private_ip_ipip, } def update_ipfile_ipip10(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_ipip10("/etc/ipip10.sh", new_ip, update_type="ipip_local") update_ipfile_ipip10( "/etc/ipip10.sh", counterpart_ip, update_type="ipip_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipip_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "ipip_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_ipip10(private_ip, local_ip, remote_ip, is_ipip): current_ips = get_current_private_ipsipip10() current_ip = current_ips["ipip"] if is_ipip else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_ipip: update_pingfile_sit("/etc/ping_ip10.sh", counterpart_ip) update_ipfile_ipip10("/etc/ipip10.sh", private_ip, update_type="private") update_ipfile_ipip10("/etc/ipip10.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v610.sh", counterpart_ip) update_ipfile_ipip10("/etc/private10.sh", private_ip, update_type="private") update_ipfile_ipip10("/etc/private10.sh", local_ip, update_type="local") update_ipfile_ipip10("/etc/private10.sh", remote_ip, update_type="remote") interface = "azumip10" if is_ipip else "azumi10" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/ipip10.sh" if is_ipip else "/etc/private10.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v610"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip10"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91merror applying network changes\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def ipipkharej10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_ipip = local_ip("/etc/ipip10.sh") remote_ip_ipip = remote_ip("/etc/ipip10.sh") private_ip_ipip = private_ipip1("/etc/ipip10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej [10] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [10] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip10( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip10( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipir10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_ipip = local_ip("/etc/ipip10.sh") remote_ip_ipip = remote_ip("/etc/ipip10.sh") private_ip_ipip = private_ipip1("/etc/ipip10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [10] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip10( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip10( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 10 iran 1 kharej ipip def ipipiranfive1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone1_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_ipip = local_ip("/etc/ipip1.sh") remote_ip_ipip = remote_ip("/etc/ipip1.sh") private_ip_ipip = private_ipip1("/etc/ipip1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip1( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip1( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 2 ipip 10 iran 1 kharej def ipipiranfive2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone2_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_ipip = local_ip("/etc/ipip2.sh") remote_ip_ipip = remote_ip("/etc/ipip2.sh") private_ip_ipip = private_ipip1("/etc/ipip2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip2( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip2( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 3 ipip 10 iran 1 kharej def ipipiranfive3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone3_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_ipip = local_ip("/etc/ipip3.sh") remote_ip_ipip = remote_ip("/etc/ipip3.sh") private_ip_ipip = private_ipip1("/etc/ipip3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip3( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip3( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 4 ipip 10 iran 1 kharej def ipipiranfive4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone4_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_ipip = local_ip("/etc/ipip4.sh") remote_ip_ipip = remote_ip("/etc/ipip4.sh") private_ip_ipip = private_ipip1("/etc/ipip4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip4( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip4( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 5 ipip 10 iran 1 kharej def ipipiranfive5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone5_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_ipip = local_ip("/etc/ipip5.sh") remote_ip_ipip = remote_ip("/etc/ipip5.sh") private_ip_ipip = private_ipip1("/etc/ipip5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip5( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip5( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 6 ipip 10 iran 1 kharej def display_stuff_privateiranfive6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[6]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[6]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def ipipiranfive6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_ipip = local_ip("/etc/ipip6.sh") remote_ip_ipip = remote_ip("/etc/ipip6.sh") private_ip_ipip = private_ipip1("/etc/ipip6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [6] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [6] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [6]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip6( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip6( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone6_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_ipip = local_ip("/etc/ipip6.sh") remote_ip_ipip = remote_ip("/etc/ipip6.sh") private_ip_ipip = private_ipip1("/etc/ipip6.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [6] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [6]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip6( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip6( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 7 ipip 10 iran 1 kharej def display_stuff_privateiranfive7(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[7]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone7(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[7]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def ipipiranfive7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_ipip = local_ip("/etc/ipip7.sh") remote_ip_ipip = remote_ip("/etc/ipip7.sh") private_ip_ipip = private_ipip1("/etc/ipip7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [7] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [7] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [7]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip7( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip7( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone7_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_ipip = local_ip("/etc/ipip7.sh") remote_ip_ipip = remote_ip("/etc/ipip7.sh") private_ip_ipip = private_ipip1("/etc/ipip7.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [7] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [7]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip7( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip7( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 8 ipip 10 iran 1 kharej def display_stuff_privateiranfive8(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[8]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone8(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[8]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def ipipiranfive8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_ipip = local_ip("/etc/ipip8.sh") remote_ip_ipip = remote_ip("/etc/ipip8.sh") private_ip_ipip = private_ipip1("/etc/ipip8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [8] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [8] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [8]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip8( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip8( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone8_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_ipip = local_ip("/etc/ipip8.sh") remote_ip_ipip = remote_ip("/etc/ipip8.sh") private_ip_ipip = private_ipip1("/etc/ipip8.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [8] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [8]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip8( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip8( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 9 ipip 10 iran 1 kharej def display_stuff_privateiranfive9(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[9]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone9(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[9]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def ipipiranfive9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_ipip = local_ip("/etc/ipip9.sh") remote_ip_ipip = remote_ip("/etc/ipip9.sh") private_ip_ipip = private_ipip1("/etc/ipip9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [9] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [9] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [9]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip9( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip9( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone9_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_ipip = local_ip("/etc/ipip9.sh") remote_ip_ipip = remote_ip("/etc/ipip9.sh") private_ip_ipip = private_ipip1("/etc/ipip9.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [9] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [9]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip9( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip9( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 10 ipip 10 iran 1 kharej def display_stuff_privateiranfive10(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[93mIRAN \033[96m[10]\033[93m Public IP: \033[97m{local_ip}\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_privatekharejone10(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: SIT Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{local_ip}\033[0m", f"\033[93mIRAN \033[96m[10]\033[93m Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mSIT Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def ipipiranfive10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_ipip = local_ip("/etc/ipip10.sh") remote_ip_ipip = remote_ip("/etc/ipip10.sh") private_ip_ipip = private_ipip1("/etc/ipip10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m IRAN [10] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [10] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mIRAN [10]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip10( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip10( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def ipipkharejone10_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_ipip = local_ip("/etc/ipip10.sh") remote_ip_ipip = remote_ip("/etc/ipip10.sh") private_ip_ipip = private_ipip1("/etc/ipip10.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip: print("couldn't retrieve IP addresses from ipip file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_ipip or not remote_ip_ipip or not private_ip_ipip ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_ip6ip6(local_ip_ipip, remote_ip_ipip, private_ip_ipip) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [10] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mIP6IP6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_ipip = new_ip remote_ip_ipip = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[IP6IP6]\033[93m :\033[0m " ) if new_ip: private_ip_ipip = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mIRAN [10]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_ipip10( private_ip_private, local_ip_private, remote_ip_private, is_ipip=False, ) save_stuff_ipip10( private_ip_ipip, local_ip_ipip, remote_ip_ipip, is_ipip=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6nosec_multiedit_local() break elif choice == "2": gre6sec_multiedit_local() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") # ipsec menu def gre6sec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6sec_edit_localkharej_multi() break elif choice == "2": gre6sec_edit_localiran_multi() break elif choice == "3": clear() gre6_multiedit_local() break else: print("Invalid choice.") def gre6sec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6iranfive1sec_editmulti_local() break elif server_type == "2": gre6iranfive2sec_editmulti_local() break elif server_type == "3": gre6iranfive3sec_editmulti_local() break elif server_type == "4": gre6iranfive4sec_editmulti_local() break elif server_type == "5": gre6iranfive5sec_editmulti_local() break elif server_type == "6": gre6kharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gre6sec_multiedit_local() break else: print("Invalid choice.") def gre6kharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6kharejone1sec_editmulti_local() break elif server_type == "2": gre6kharejone2sec_editmulti_local() break elif server_type == "3": gre6kharejone3sec_editmulti_local() break elif server_type == "4": gre6kharejone4sec_editmulti_local() break elif server_type == "5": gre6kharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") gre6sec_multiedit_local() break else: print("Invalid choice.") def gre6sec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6kharej1sec_editmulti_local() break elif server_type == "2": gre6kharej2sec_editmulti_local() break elif server_type == "3": gre6kharej3sec_editmulti_local() break elif server_type == "4": gre6kharej4sec_editmulti_local() break elif server_type == "5": gre6kharej5sec_editmulti_local() break elif server_type == "6": gre6iransec_editmulti_local() break elif server_type == "0": os.system("clear") gre6sec_multiedit_local() break else: print("Invalid choice.") def gre6iransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6ir1sec_editmulti_local() break elif server_type == "2": gre6ir2sec_editmulti_local() break elif server_type == "3": gre6ir3sec_editmulti_local() break elif server_type == "4": gre6ir4sec_editmulti_local() break elif server_type == "5": gre6ir5sec_editmulti_local() break elif server_type == "0": os.system("clear") gre6sec_multiedit_local() break else: print("Invalid choice.") def gre6nosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6nosec_edit_localkharej_multi() break elif choice == "2": gre6nosec_edit_localiran_multi() break elif choice == "3": clear() gre6_multiedit_local() break else: print("Invalid choice.") def gre6nosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6iranfive1nosec_editmulti_local() break elif server_type == "2": gre6iranfive2nosec_editmulti_local() break elif server_type == "3": gre6iranfive3nosec_editmulti_local() break elif server_type == "4": gre6iranfive4nosec_editmulti_local() break elif server_type == "5": gre6iranfive5nosec_editmulti_local() break elif server_type == "6": gre6kharejonenosec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gre6nosec_multiedit_local() break else: print("Invalid choice.") def gre6kharejonenosec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6kharejone1nosec_editmulti_local() break elif server_type == "2": gre6kharejone2nosec_editmulti_local() break elif server_type == "3": gre6kharejone3nosec_editmulti_local() break elif server_type == "4": gre6kharejone4nosec_editmulti_local() break elif server_type == "5": gre6kharejone5nosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6nosec_multiedit_local() break else: print("Invalid choice.") def gre6nosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6kharej1nosec_editmulti_local() break elif server_type == "2": gre6kharej2nosec_editmulti_local() break elif server_type == "3": gre6kharej3nosec_editmulti_local() break elif server_type == "4": gre6kharej4nosec_editmulti_local() break elif server_type == "5": gre6kharej5nosec_editmulti_local() break elif server_type == "6": gre6kharej6nosec_editmulti_local() break elif server_type == "7": gre6kharej7nosec_editmulti_local() break elif server_type == "8": gre6kharej8nosec_editmulti_local() break elif server_type == "9": gre6kharej9nosec_editmulti_local() break elif server_type == "10": gre6kharej10nosec_editmulti_local() break elif server_type == "6": gre6irannosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6nosec_multiedit_local() break else: print("Invalid choice.") def gre6irannosec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6ir1nosec_editmulti_local() break elif server_type == "2": gre6ir2nosec_editmulti_local() break elif server_type == "3": gre6ir3nosec_editmulti_local() break elif server_type == "4": gre6ir4nosec_editmulti_local() break elif server_type == "5": gre6ir5nosec_editmulti_local() break elif server_type == "6": gre6ir6nosec_editmulti_local() break elif server_type == "7": gre6ir7nosec_editmulti_local() break elif server_type == "8": gre6ir8nosec_editmulti_local() break elif server_type == "9": gre6ir9nosec_editmulti_local() break elif server_type == "10": gre6ir10nosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6nosec_multiedit_local() break else: print("Invalid choice.") def private_gre6multi(name): try: with open(name, "r") as f: content = f.read() match = re.search(r"ip -6 addr add (\S+)/64 dev azumig6?", content) if match: return match.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print("\033[91mPrivate file not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def display_stuff_gre6(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6 Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") # changes # 1 def update_ipfile_gre61(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre61("/etc/gre61.sh", new_ip, update_type="gre6_local") update_ipfile_gre61( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre61(): private_ip_private = private_ip1("/etc/private1.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec1(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre61() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_gre61("/etc/gre61.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/gre61.sh", remote_ip, update_type="remote") update_ipfile_gre61("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_gre61("/etc/private1.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/private1.sh", local_ip, update_type="local") update_ipfile_gre61("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumig61" if is_gre6 else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_irangre61(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE61": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE61' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE61' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre6sec1_iran(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre61() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_gre61("/etc/gre61.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/gre61.sh", remote_ip, update_type="remote") update_ipsec_conf_irangre61("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_gre61("/etc/private1.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/private1.sh", local_ip, update_type="local") update_ipfile_gre61("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumig61" if is_gre6 else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def gre6kharej1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre61("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6ir1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre61("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes # 2 def update_ipfile_gre62(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre62("/etc/gre62.sh", new_ip, update_type="gre6_local") update_ipfile_gre62( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre62(): private_ip_private = private_ip1("/etc/private2.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec2(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre62() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_gre62("/etc/gre62.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/gre62.sh", remote_ip, update_type="remote") update_ipfile_gre62("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_gre62("/etc/private2.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/private2.sh", local_ip, update_type="local") update_ipfile_gre62("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumig62" if is_gre6 else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_irangre62(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE62": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE62' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE62' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre6sec2_iran(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre62() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_gre62("/etc/gre62.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/gre62.sh", remote_ip, update_type="remote") update_ipsec_conf_irangre62("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_gre62("/etc/private2.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/private2.sh", local_ip, update_type="local") update_ipfile_gre62("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumig62" if is_gre6 else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def gre6kharej2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre62("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6ir2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre62("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi2(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes # 3 def update_ipfile_gre63(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre63("/etc/gre63.sh", new_ip, update_type="gre6_local") update_ipfile_gre63( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre63(): private_ip_private = private_ip1("/etc/private3.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec3(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre63() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_gre63("/etc/gre63.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/gre63.sh", remote_ip, update_type="remote") update_ipfile_gre63("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_gre63("/etc/private3.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/private3.sh", local_ip, update_type="local") update_ipfile_gre63("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumig63" if is_gre6 else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_irangre63(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE63": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE63' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE63' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre6sec3_iran(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre63() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_gre63("/etc/gre63.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/gre63.sh", remote_ip, update_type="remote") update_ipsec_conf_irangre63("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_gre63("/etc/private3.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/private3.sh", local_ip, update_type="local") update_ipfile_gre63("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumig63" if is_gre6 else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def gre6kharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre63("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6ir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre63("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi3(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes # 4 def update_ipfile_gre64(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre64("/etc/gre64.sh", new_ip, update_type="gre6_local") update_ipfile_gre64( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre64(): private_ip_private = private_ip1("/etc/private4.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec4(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre64() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_gre64("/etc/gre64.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/gre64.sh", remote_ip, update_type="remote") update_ipfile_gre64("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_gre64("/etc/private4.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/private4.sh", local_ip, update_type="local") update_ipfile_gre64("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumig64" if is_gre6 else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_irangre64(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE64": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE64' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE64' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre6sec4_iran(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre64() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_gre64("/etc/gre64.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/gre64.sh", remote_ip, update_type="remote") update_ipsec_conf_irangre64("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_gre64("/etc/private4.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/private4.sh", local_ip, update_type="local") update_ipfile_gre64("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumig64" if is_gre6 else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def gre6kharej4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre64("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6ir4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre64("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi4(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # changes # 5 def update_ipfile_gre65(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre65("/etc/gre65.sh", new_ip, update_type="gre6_local") update_ipfile_gre65( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgre65(): private_ip_private = private_ip1("/etc/private5.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def save_stuff_gre6sec5(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre65() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_gre65("/etc/gre65.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/gre65.sh", remote_ip, update_type="remote") update_ipfile_gre65("/etc/ipsec1.conf", private_ip, update_type="ipsec") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_gre65("/etc/private5.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/private5.sh", local_ip, update_type="local") update_ipfile_gre65("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumig65" if is_gre6 else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def update_ipsec_conf_irangre65(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn GRE65": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn GRE65' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn GRE65' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre6sec5_iran(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre65() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_gre65("/etc/gre65.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/gre65.sh", remote_ip, update_type="remote") update_ipsec_conf_irangre65("/etc/ipsec1.conf", private_ip) else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_gre65("/etc/private5.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/private5.sh", local_ip, update_type="local") update_ipfile_gre65("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumig65" if is_gre6 else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print("\033[91merror bringing interface down or deleting it\033[0m") try: script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( [ "systemctl", "list-units", "--full", "--all", "strong-azumi1.service", ], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print("\033[91mstrongswan service not found, don't mind this error.\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # animate("\033[92mSystem services reloaded and restarted successfully!\033[0m") def gre6kharej5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre65("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6ir5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre65("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi5(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre6sec 5 iran 1 kharej def gre6iranfive1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre61("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6kharejone1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre61("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre6sec 5 iran 1 kharej #2 def gre6iranfive2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre62("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6kharejone2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre62("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi2(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre6sec 5 iran 1 kharej #3 def gre6iranfive3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre63("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6kharejone3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre63("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi3(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre6sec 5 iran 1 kharej #4 def gre6iranfive4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre64("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6kharejone4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre64("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi4(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre6sec 5 iran 1 kharej #5 def gre6iranfive5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre65("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6kharejone5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre65("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi5(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # gre61 def save_stuff_gre61(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre61() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip1.sh", counterpart_ip) update_ipfile_gre61("/etc/gre61.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/gre61.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v61.sh", counterpart_ip) update_ipfile_gre61("/etc/private1.sh", private_ip, update_type="private") update_ipfile_gre61("/etc/private1.sh", local_ip, update_type="local") update_ipfile_gre61("/etc/private1.sh", remote_ip, update_type="remote") interface = "azumig61" if is_gre6 else "azumi1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v61"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre62 def save_stuff_gre62(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre62() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip2.sh", counterpart_ip) update_ipfile_gre62("/etc/gre62.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/gre62.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v62.sh", counterpart_ip) update_ipfile_gre62("/etc/private2.sh", private_ip, update_type="private") update_ipfile_gre62("/etc/private2.sh", local_ip, update_type="local") update_ipfile_gre62("/etc/private2.sh", remote_ip, update_type="remote") interface = "azumig62" if is_gre6 else "azumi2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v62"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre63 def save_stuff_gre63(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre63() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip3.sh", counterpart_ip) update_ipfile_gre63("/etc/gre63.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/gre63.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v63.sh", counterpart_ip) update_ipfile_gre63("/etc/private3.sh", private_ip, update_type="private") update_ipfile_gre63("/etc/private3.sh", local_ip, update_type="local") update_ipfile_gre63("/etc/private3.sh", remote_ip, update_type="remote") interface = "azumig63" if is_gre6 else "azumi3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v63"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre64 def save_stuff_gre64(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre64() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip4.sh", counterpart_ip) update_ipfile_gre64("/etc/gre64.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/gre64.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v64.sh", counterpart_ip) update_ipfile_gre64("/etc/private4.sh", private_ip, update_type="private") update_ipfile_gre64("/etc/private4.sh", local_ip, update_type="local") update_ipfile_gre64("/etc/private4.sh", remote_ip, update_type="remote") interface = "azumig64" if is_gre6 else "azumi4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v64"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre65 def save_stuff_gre65(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre65() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip5.sh", counterpart_ip) update_ipfile_gre65("/etc/gre65.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/gre65.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v65.sh", counterpart_ip) update_ipfile_gre65("/etc/private5.sh", private_ip, update_type="private") update_ipfile_gre65("/etc/private5.sh", local_ip, update_type="local") update_ipfile_gre65("/etc/private5.sh", remote_ip, update_type="remote") interface = "azumig65" if is_gre6 else "azumi5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v65"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre66 def get_current_private_ipsgre66(): private_ip_private = private_ip1("/etc/private6.sh") private_ip_gre6 = private_gre6multi("/etc/gre66.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def update_ipfile_gre66(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre66("/etc/gre66.sh", new_ip, update_type="gre6_local") update_ipfile_gre66( "/etc/gre66.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre66(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre66() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip6.sh", counterpart_ip) update_ipfile_gre66("/etc/gre66.sh", private_ip, update_type="private") update_ipfile_gre66("/etc/gre66.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v66.sh", counterpart_ip) update_ipfile_gre66("/etc/private6.sh", private_ip, update_type="private") update_ipfile_gre66("/etc/private6.sh", local_ip, update_type="local") update_ipfile_gre66("/etc/private6.sh", remote_ip, update_type="remote") interface = "azumig66" if is_gre6 else "azumi6" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre66.sh" if is_gre6 else "/etc/private6.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v66"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip6"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej6nosec_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_gre6 = local_ip("/etc/gre66.sh") remote_ip_gre6 = remote_ip("/etc/gre66.sh") private_ip_gre6 = private_gre6multi("/etc/gre66.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [6] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [6] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre66( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre66( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir6nosec_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_gre6 = local_ip("/etc/gre66.sh") remote_ip_gre6 = remote_ip("/etc/gre66.sh") private_ip_gre6 = private_gre6multi("/etc/gre66.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [6] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre66( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre66( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre67 def get_current_private_ipsgre67(): private_ip_private = private_ip1("/etc/private7.sh") private_ip_gre6 = private_gre6multi("/etc/gre67.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def update_ipfile_gre67(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre67("/etc/gre67.sh", new_ip, update_type="gre6_local") update_ipfile_gre67( "/etc/gre67.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre67(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre67() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip7.sh", counterpart_ip) update_ipfile_gre67("/etc/gre67.sh", private_ip, update_type="private") update_ipfile_gre67("/etc/gre67.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v67.sh", counterpart_ip) update_ipfile_gre67("/etc/private7.sh", private_ip, update_type="private") update_ipfile_gre67("/etc/private7.sh", local_ip, update_type="local") update_ipfile_gre67("/etc/private7.sh", remote_ip, update_type="remote") interface = "azumig67" if is_gre6 else "azumi7" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre67.sh" if is_gre6 else "/etc/private7.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v67"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip7"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej7nosec_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_gre6 = local_ip("/etc/gre67.sh") remote_ip_gre6 = remote_ip("/etc/gre67.sh") private_ip_gre6 = private_gre6multi("/etc/gre67.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [7] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [7] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre67( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre67( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir7nosec_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_gre6 = local_ip("/etc/gre67.sh") remote_ip_gre6 = remote_ip("/etc/gre67.sh") private_ip_gre6 = private_gre6multi("/etc/gre67.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [7] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre67( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre67( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre68 def get_current_private_ipsgre68(): private_ip_private = private_ip1("/etc/private8.sh") private_ip_gre6 = private_gre6multi("/etc/gre68.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def update_ipfile_gre68(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre68("/etc/gre68.sh", new_ip, update_type="gre6_local") update_ipfile_gre68( "/etc/gre68.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre68(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre68() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip8.sh", counterpart_ip) update_ipfile_gre68("/etc/gre68.sh", private_ip, update_type="private") update_ipfile_gre68("/etc/gre68.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v68.sh", counterpart_ip) update_ipfile_gre68("/etc/private8.sh", private_ip, update_type="private") update_ipfile_gre68("/etc/private8.sh", local_ip, update_type="local") update_ipfile_gre68("/etc/private8.sh", remote_ip, update_type="remote") interface = "azumig68" if is_gre6 else "azumi8" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre68.sh" if is_gre6 else "/etc/private8.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v68"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip8"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej8nosec_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_gre6 = local_ip("/etc/gre68.sh") remote_ip_gre6 = remote_ip("/etc/gre68.sh") private_ip_gre6 = private_gre6multi("/etc/gre68.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [8] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [8] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre68( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre68( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir8nosec_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_gre6 = local_ip("/etc/gre68.sh") remote_ip_gre6 = remote_ip("/etc/gre68.sh") private_ip_gre6 = private_gre6multi("/etc/gre68.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [8] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre68( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre68( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre69 def get_current_private_ipsgre69(): private_ip_private = private_ip1("/etc/private9.sh") private_ip_gre6 = private_gre6multi("/etc/gre69.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def update_ipfile_gre69(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre69("/etc/gre69.sh", new_ip, update_type="gre6_local") update_ipfile_gre69( "/etc/gre69.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre69(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre69() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip9.sh", counterpart_ip) update_ipfile_gre69("/etc/gre69.sh", private_ip, update_type="private") update_ipfile_gre69("/etc/gre69.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v69.sh", counterpart_ip) update_ipfile_gre69("/etc/private9.sh", private_ip, update_type="private") update_ipfile_gre69("/etc/private9.sh", local_ip, update_type="local") update_ipfile_gre69("/etc/private9.sh", remote_ip, update_type="remote") interface = "azumig69" if is_gre6 else "azumi9" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre69.sh" if is_gre6 else "/etc/private9.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v69"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip9"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej9nosec_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_gre6 = local_ip("/etc/gre69.sh") remote_ip_gre6 = remote_ip("/etc/gre69.sh") private_ip_gre6 = private_gre6multi("/etc/gre69.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [9] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [9] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre69( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre69( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir9nosec_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_gre6 = local_ip("/etc/gre69.sh") remote_ip_gre6 = remote_ip("/etc/gre69.sh") private_ip_gre6 = private_gre6multi("/etc/gre69.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [9] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre69( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre69( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # gre610 def get_current_private_ipsgre610(): private_ip_private = private_ip1("/etc/private10.sh") private_ip_gre6 = private_gre6multi("/etc/gre610.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, } def update_ipfile_gre610(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfile_gre610("/etc/gre610.sh", new_ip, update_type="gre6_local") update_ipfile_gre610( "/etc/gre610.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": new_content = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) ip_parts = new_ip.split(":") if new_ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" counterpart_ip = ":".join(ip_parts) new_content = re.sub(r"right=\S+", f"right={counterpart_ip}", new_content) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gre610(private_ip, local_ip, remote_ip, is_gre6): current_ips = get_current_private_ipsgre610() current_ip = current_ips["gre6"] if is_gre6 else current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) counterpart_ip = wtb_opposite_ip(private_ip) try: if is_gre6: update_pingfile_sit("/etc/ping_ip10.sh", counterpart_ip) update_ipfile_gre610("/etc/gre610.sh", private_ip, update_type="private") update_ipfile_gre610("/etc/gre610.sh", remote_ip, update_type="remote") else: update_pingfile_sit("/etc/ping_v610.sh", counterpart_ip) update_ipfile_gre610("/etc/private10.sh", private_ip, update_type="private") update_ipfile_gre610("/etc/private10.sh", local_ip, update_type="local") update_ipfile_gre610("/etc/private10.sh", remote_ip, update_type="remote") interface = "azumig610" if is_gre6 else "azumi10" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError as e: print(f"\033[91merror bringing interface down or deleting it: {e}\033[0m") try: script = "/etc/gre610.sh" if is_gre6 else "/etc/private10.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_v610"], check=True) subprocess.run(["sudo", "systemctl", "restart", "ping_ip10"], check=True) # display_checkmark("\033[92mSystem services reloaded and restarted successfully!\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91merror applying network changes: Gre6 related error\033[0m") except FileNotFoundError: print(f"\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gre6kharej10nosec_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_gre6 = local_ip("/etc/gre610.sh") remote_ip_gre6 = remote_ip("/etc/gre610.sh") private_ip_gre6 = private_gre6multi("/etc/gre610.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej [10] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [10] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre610( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre610( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6ir10nosec_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_gre6 = local_ip("/etc/gre610.sh") remote_ip_gre6 = remote_ip("/etc/gre610.sh") private_ip_gre6 = private_gre6multi("/etc/gre610.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [10] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre610( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre610( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #1 def gre6iranfive1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6kharejone1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #2 def gre6iranfive2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6kharejone2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #3 def gre6iranfive3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6kharejone3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #4 def gre6iranfive4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6kharejone4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #5 def gre6iranfive5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6kharejone5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def display_stuff_gre6tap(local_ip, remote_ip, private_ip): lines = [ f"\033[93mTitle: GRE6TAP Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mLocal IP: \033[97m{local_ip}\033[0m", f"\033[92mRemote IP: \033[97m{remote_ip}\033[0m", f"\033[93mPrivate IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def gre6tap_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosec_multiedit_local() break elif choice == "2": gre6tapsec_multiedit_local() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") # gre6 menu def gre6tapnosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6TAP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapnosec_edit_localkharej_multi() break elif choice == "2": gre6tapnosec_edit_localiran_multi() break elif choice == "3": clear() gre6tap_multiedit_local() break else: print("Invalid choice.") def gre6tapnosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapiranfive1nosec_editmulti_local() break elif server_type == "2": gre6tapiranfive2nosec_editmulti_local() break elif server_type == "3": gre6tapiranfive3nosec_editmulti_local() break elif server_type == "4": gre6tapiranfive4nosec_editmulti_local() break elif server_type == "5": gre6tapiranfive5nosec_editmulti_local() break elif server_type == "6": gre6tapkharejonenosec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gre6tapnosec_multiedit_local() break else: print("Invalid choice.") def gre6tapkharejonenosec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapkharejone1nosec_editmulti_local() break elif server_type == "2": gre6tapkharejone2nosec_editmulti_local() break elif server_type == "3": gre6tapkharejone3nosec_editmulti_local() break elif server_type == "4": gre6tapkharejone4nosec_editmulti_local() break elif server_type == "5": gre6tapkharejone5nosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapnosec_multiedit_local() break else: print("Invalid choice.") def gre6tapnosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapkharej1nosec_editmulti_local() break elif server_type == "2": gre6tapkharej2nosec_editmulti_local() break elif server_type == "3": gre6tapkharej3nosec_editmulti_local() break elif server_type == "4": gre6tapkharej4nosec_editmulti_local() break elif server_type == "5": gre6tapkharej5nosec_editmulti_local() break elif server_type == "6": gre6tapkharej6nosec_editmulti_local() break elif server_type == "7": gre6tapkharej7nosec_editmulti_local() break elif server_type == "8": gre6tapkharej8nosec_editmulti_local() break elif server_type == "9": gre6tapkharej9nosec_editmulti_local() break elif server_type == "10": gre6tapkharej10nosec_editmulti_local() break elif server_type == "6": gre6tapirannosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapnosec_multiedit_local() break else: print("Invalid choice.") def gre6tapirannosec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapir1nosec_editmulti_local() break elif server_type == "2": gre6tapir2nosec_editmulti_local() break elif server_type == "3": gre6tapir3nosec_editmulti_local() break elif server_type == "4": gre6tapir4nosec_editmulti_local() break elif server_type == "5": gre6tapir5nosec_editmulti_local() break elif server_type == "6": gre6tapir6nosec_editmulti_local() break elif server_type == "7": gre6tapir7nosec_editmulti_local() break elif server_type == "8": gre6tapir8nosec_editmulti_local() break elif server_type == "9": gre6tapir9nosec_editmulti_local() break elif server_type == "10": gre6tapir10nosec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapnosec_multiedit_local() break else: print("Invalid choice.") def gre6tapkharej1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6TAP\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6TAP \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej6nosec_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_gre6 = local_ip("/etc/gre66.sh") remote_ip_gre6 = remote_ip("/etc/gre66.sh") private_ip_gre6 = private_gre6multi("/etc/gre66.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [6] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [6] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre66( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre66( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir6nosec_editmulti_local(): local_ip_private = local_ip("/etc/private6.sh") remote_ip_private = remote_ip("/etc/private6.sh") private_ip_private = private_ip1("/etc/private6.sh") local_ip_gre6 = local_ip("/etc/gre66.sh") remote_ip_gre6 = remote_ip("/etc/gre66.sh") private_ip_gre6 = private_gre6multi("/etc/gre66.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran6( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [6] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [6]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre66( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre66( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej7nosec_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_gre6 = local_ip("/etc/gre67.sh") remote_ip_gre6 = remote_ip("/etc/gre67.sh") private_ip_gre6 = private_gre6multi("/etc/gre67.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [7] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [7] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre67( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre67( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir7nosec_editmulti_local(): local_ip_private = local_ip("/etc/private7.sh") remote_ip_private = remote_ip("/etc/private7.sh") private_ip_private = private_ip1("/etc/private7.sh") local_ip_gre6 = local_ip("/etc/gre67.sh") remote_ip_gre6 = remote_ip("/etc/gre67.sh") private_ip_gre6 = private_gre6multi("/etc/gre67.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran7( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [7] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [7]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre67( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre67( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej8nosec_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_gre6 = local_ip("/etc/gre68.sh") remote_ip_gre6 = remote_ip("/etc/gre68.sh") private_ip_gre6 = private_gre6multi("/etc/gre68.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [8] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [8] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre68( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre68( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir8nosec_editmulti_local(): local_ip_private = local_ip("/etc/private8.sh") remote_ip_private = remote_ip("/etc/private8.sh") private_ip_private = private_ip1("/etc/private8.sh") local_ip_gre6 = local_ip("/etc/gre68.sh") remote_ip_gre6 = remote_ip("/etc/gre68.sh") private_ip_gre6 = private_gre6multi("/etc/gre68.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran8( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [8] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [8]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre68( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre68( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej9nosec_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_gre6 = local_ip("/etc/gre69.sh") remote_ip_gre6 = remote_ip("/etc/gre69.sh") private_ip_gre6 = private_gre6multi("/etc/gre69.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [9] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [9] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre69( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre69( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir9nosec_editmulti_local(): local_ip_private = local_ip("/etc/private9.sh") remote_ip_private = remote_ip("/etc/private9.sh") private_ip_private = private_ip1("/etc/private9.sh") local_ip_gre6 = local_ip("/etc/gre69.sh") remote_ip_gre6 = remote_ip("/etc/gre69.sh") private_ip_gre6 = private_gre6multi("/etc/gre69.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran9( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [9] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [9]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre69( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre69( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharej10nosec_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_gre6 = local_ip("/etc/gre610.sh") remote_ip_gre6 = remote_ip("/etc/gre610.sh") private_ip_gre6 = private_gre6multi("/etc/gre610.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej [10] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [10] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre610( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre610( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapir10nosec_editmulti_local(): local_ip_private = local_ip("/etc/private10.sh") remote_ip_private = remote_ip("/etc/private10.sh") private_ip_private = private_ip1("/etc/private10.sh") local_ip_gre6 = local_ip("/etc/gre610.sh") remote_ip_gre6 = remote_ip("/etc/gre610.sh") private_ip_gre6 = private_gre6multi("/etc/gre610.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran10( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKHAREJ [10] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [10]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre610( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre610( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #1 def gre6tapiranfive1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharejone1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre61( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre61( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #2 def gre6tapiranfive2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharejone2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre62( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre62( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #3 def gre6tapiranfive3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharejone3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre63( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre63( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #4 def gre6tapiranfive4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharejone4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre64( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre64( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran 10 kharej 1 #5 def gre6tapiranfive5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapkharejone5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": save_stuff_gre65( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre65( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gre6tapsec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m GRE6tap + IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gre6tapsec_edit_localkharej_multi() break elif choice == "2": gre6tapsec_edit_localiran_multi() break elif choice == "3": clear() gre6tap_multiedit_local() break else: print("Invalid choice.") def gre6tapsec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapiranfive1sec_editmulti_local() break elif server_type == "2": gre6tapiranfive2sec_editmulti_local() break elif server_type == "3": gre6tapiranfive3sec_editmulti_local() break elif server_type == "4": gre6tapiranfive4sec_editmulti_local() break elif server_type == "5": gre6tapiranfive5sec_editmulti_local() break elif server_type == "6": gre6tapkharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gre6tapsec_multiedit_local() break else: print("Invalid choice.") def gre6tapkharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapkharejone1sec_editmulti_local() break elif server_type == "2": gre6tapkharejone2sec_editmulti_local() break elif server_type == "3": gre6tapkharejone3sec_editmulti_local() break elif server_type == "4": gre6tapkharejone4sec_editmulti_local() break elif server_type == "5": gre6tapkharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapsec_multiedit_local() break else: print("Invalid choice.") def gre6tapsec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapkharej1sec_editmulti_local() break elif server_type == "2": gre6tapkharej2sec_editmulti_local() break elif server_type == "3": gre6tapkharej3sec_editmulti_local() break elif server_type == "4": gre6tapkharej4sec_editmulti_local() break elif server_type == "5": gre6tapkharej5sec_editmulti_local() break elif server_type == "6": gre6tapiransec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapsec_multiedit_local() break else: print("Invalid choice.") def gre6tapiransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6tap + IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapir1sec_editmulti_local() break elif server_type == "2": gre6tapir2sec_editmulti_local() break elif server_type == "3": gre6tapir3sec_editmulti_local() break elif server_type == "4": gre6tapir4sec_editmulti_local() break elif server_type == "5": gre6tapir5sec_editmulti_local() break elif server_type == "0": os.system("clear") gre6tapsec_multiedit_local() break else: print("Invalid choice.") def gre6tapkharej1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre61("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapir1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre61("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharej2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre62("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapir2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre62("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi2(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre63("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre63("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi3(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharej4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre64("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapir4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre64("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi4(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharej5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre65("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapir5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre65("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi5(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapiranfive1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre61("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharejone1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre61("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapiranfive2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre62("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharejone2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre62("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi2(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapiranfive3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre63("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharejone3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre63("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi3(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapiranfive4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre64("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharejone4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre64("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi4(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapiranfive5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipfile_gre65("/etc/ipsec1.conf", new_ip, update_type="ipsec") else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gre6tapkharejone5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6tap file") if not ipsecsecret: print("couldn't retrieve IPsec secret key from ipsec file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not ipsecsecret ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6tap(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_ipsecsecret(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m Public IP\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6tap \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange IPSEC \033[92mSecret Key\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter new private IPv6 address \033[96m[GRE6tap]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_gre6 private_ip_gre6 = new_ip update_ipsec_conf_irangre65("/etc/ipsec1.conf", new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "6": save_stuff_gre6sec5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False, ) save_stuff_gre6sec5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) update_ipsec_ip_multi5(private_ip_gre6) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def gen_multiedit_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve Private IPV4 \033[96m[Point IP]\033[0m") print("2. \033[93mGeneve Private IPV6 \033[96m[Point IP]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gen_multiedit_local() break elif choice == "2": gen_multiedit_localv6() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") def gen_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_multiedit_local() break elif choice == "2": genudpsec_multiedit_local() break elif choice == "3": clear() gen_multiedit_localmenu() break else: print("Invalid choice.") def gen_multiedit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_multiedit_localv6() break elif choice == "2": genudpsec_multiedit_localv6() break elif choice == "3": clear() gen_multiedit_localmenu() break else: print("Invalid choice.") def genudpnosec_multiedit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V6 Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_localkharej_multiv6() break elif choice == "2": genudpnosec_edit_localiran_multiv6() break elif choice == "3": clear() gen_multiedit_localv6() break else: print("Invalid choice.") def genudpnosec_edit_localiran_multiv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpiranfive1nosec_editmulti_localv6() break elif server_type == "2": genudpiranfive2nosec_editmulti_localv6() break elif server_type == "3": genudpiranfive3nosec_editmulti_localv6() break elif server_type == "4": genudpiranfive4nosec_editmulti_localv6() break elif server_type == "5": genudpiranfive5nosec_editmulti_localv6() break elif server_type == "6": genudpkharejonenosec_editmulti_localmenuv6() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_localv6() break else: print("Invalid choice.") def genudpkharejonenosec_editmulti_localmenuv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve V6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharejone1nosec_editmulti_localv6() break elif server_type == "2": genudpkharejone2nosec_editmulti_localv6() break elif server_type == "3": genudpkharejone3nosec_editmulti_localv6() break elif server_type == "4": genudpkharejone4nosec_editmulti_localv6() break elif server_type == "5": genudpkharejone5nosec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_localv6() break else: print("Invalid choice.") def genudpnosec_edit_localkharej_multiv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharej1nosec_editmulti_localv6() break elif server_type == "2": genudpkharej2nosec_editmulti_localv6() break elif server_type == "3": genudpkharej3nosec_editmulti_localv6() break elif server_type == "4": genudpkharej4nosec_editmulti_localv6() break elif server_type == "5": genudpkharej5nosec_editmulti_localv6() break elif server_type == "6": genudpirannosec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_localv6() break else: print("Invalid choice.") def genudpirannosec_editmulti_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpir1nosec_editmulti_localv6() break elif server_type == "2": genudpir2nosec_editmulti_localv6() break elif server_type == "3": genudpir3nosec_editmulti_localv6() break elif server_type == "4": genudpir4nosec_editmulti_localv6() break elif server_type == "5": genudpir5nosec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_localv6() break else: print("Invalid choice.") def genudpnosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve UDP V4 Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpnosec_edit_localkharej_multi() break elif choice == "2": genudpnosec_edit_localiran_multi() break elif choice == "3": clear() gen_multiedit_local() break else: print("Invalid choice.") def genudpnosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpiranfive1nosec_editmulti_local() break elif server_type == "2": genudpiranfive2nosec_editmulti_local() break elif server_type == "3": genudpiranfive3nosec_editmulti_local() break elif server_type == "4": genudpiranfive4nosec_editmulti_local() break elif server_type == "5": genudpiranfive5nosec_editmulti_local() break elif server_type == "6": genudpkharejonenosec_editmulti_localmenu() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_local() break else: print("Invalid choice.") def genudpkharejonenosec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve V4 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharejone1nosec_editmulti_local() break elif server_type == "2": genudpkharejone2nosec_editmulti_local() break elif server_type == "3": genudpkharejone3nosec_editmulti_local() break elif server_type == "4": genudpkharejone4nosec_editmulti_local() break elif server_type == "5": genudpkharejone5nosec_editmulti_local() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_local() break else: print("Invalid choice.") def genudpnosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharej1nosec_editmulti_local() break elif server_type == "2": genudpkharej2nosec_editmulti_local() break elif server_type == "3": genudpkharej3nosec_editmulti_local() break elif server_type == "4": genudpkharej4nosec_editmulti_local() break elif server_type == "5": genudpkharej5nosec_editmulti_local() break elif server_type == "6": genudpirannosec_editmulti_local() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_local() break else: print("Invalid choice.") def genudpirannosec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpir1nosec_editmulti_local() break elif server_type == "2": genudpir2nosec_editmulti_local() break elif server_type == "3": genudpir3nosec_editmulti_local() break elif server_type == "4": genudpir4nosec_editmulti_local() break elif server_type == "5": genudpir5nosec_editmulti_local() break elif server_type == "0": os.system("clear") genudpnosec_multiedit_local() break else: print("Invalid choice.") # server 1 def genudpir1nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck1(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej1nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 2 def genudpir2nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck2(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej2nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 3 def genudpir3nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck3(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej3nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 4 def genudpir4nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck4(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej4nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server def genudpir5nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck5(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej5nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # iran 5 kharej 1 v6 #1 def genudpiranfive1nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone1nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran1(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 2 def genudpiranfive2nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone2nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran2(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 3 def genudpiranfive3nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone3nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran3(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 4 def genudpiranfive4nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone4nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran4(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 5 def genudpiranfive5nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V4\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone5nosec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran5(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def update_ipfile_gen(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": if ":" in new_ip: new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) else: new_content = re.sub( r"ip addr add \d+\.\d+\.\d+\.\d+/32 dev azumigen?", f"ip addr add {new_ip}/32 dev azumigen", content, ) ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"ip route add \d+\.\d+\.\d+\.\d+/32 dev azumigen?", f"ip route add {counterpart_ip}/32 dev azumigen", new_content, ) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def display_stuff_gennoseci(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") # server 1 def display_stuff_gennoseck1(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [1] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen1(private_ip, remote_ip): current_ips = get_current_private_ipsgen_multi1() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping1_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys1.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys1.sh", remote_ip, update_type="remote") interface = "azumigen1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping1_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping1_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping1_gen.service: Unit ping1_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff : gen udp no sec error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir1nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck1(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej1nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 2 def display_stuff_gennoseck2(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [2] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen2(private_ip, remote_ip): current_ips = get_current_private_ipsgen_multi2() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping2_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys2.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys2.sh", remote_ip, update_type="remote") interface = "azumigen2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping2_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping2_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping2_gen.service: Unit ping2_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff : gen udp no sec error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir2nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck2(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej2nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 3 def display_stuff_gennoseck3(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [3] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen3(private_ip, remote_ip): current_ips = get_current_private_ipsgen_multi3() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping3_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys3.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys3.sh", remote_ip, update_type="remote") interface = "azumigen3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping3_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping3_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping3_gen.service: Unit ping3_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff : gen udp no sec error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir3nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck3(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej3nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 4 def display_stuff_gennoseck4(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [4] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen4(private_ip, remote_ip): current_ips = get_current_private_ipsgen_multi4() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping4_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys4.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys4.sh", remote_ip, update_type="remote") interface = "azumigen4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping4_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping4_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping4_gen.service: Unit ping4_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff : gen udp no sec error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir4nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck4(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej4nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # server 5 def display_stuff_gennoseck5(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [5] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def save_stuff_gen5(private_ip, remote_ip): current_ips = get_current_private_ipsgen_multi5() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) try: update_pingfilegen("/etc/ping5_sys.sh", opposite_private_ip) update_ipfile_gen("/etc/sys5.sh", private_ip, update_type="private") update_ipfile_gen("/etc/sys5.sh", remote_ip, update_type="remote") interface = "azumigen5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in (result.stderr or ""): print("interface already exists, don't mind this") else: result.check_returncode() print( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping5_gen.service"], check=True ) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping5_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping5_gen.service: Unit ping5_gen.service not found.\033[0m" ) else: raise except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff : gen udp no sec error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir5nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseck5(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej5nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseci(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # iran 5 kharej 1 v6 #1 def display_stuff_gennoseckharej(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_gennoseciran1(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [1] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpiranfive1nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone1nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran1(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen1(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 2 def display_stuff_gennoseciran2(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [2] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpiranfive2nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone2nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran2(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen2(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 3 def display_stuff_gennoseciran3(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [3] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpiranfive3nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone3nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran3(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen3(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 4 def display_stuff_gennoseciran4(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [4] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpiranfive4nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone4nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran4(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen4(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 5 def display_stuff_gennoseciran5(remote_ip, private_ip): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [5] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpiranfive5nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseckharej(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone5nosec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") if not remote_ip_private or not private_ip_private: print("Couldn't retrieve IP addresses from Private file") return while True: os.system("clear") display_stuff_gennoseciran5(remote_ip_private, private_ip_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("2.\033[93m Change \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": save_stuff_gen5(private_ip_private, remote_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpsec_multiedit_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve + IPSEC UDP V6 Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpsec_edit_localkharej_multiv6() break elif choice == "2": genudpsec_edit_localiran_multiv6() break elif choice == "3": clear() gen_multiedit_localv6() break else: print("Invalid choice.") def genudpsec_edit_localiran_multiv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpiranfive1sec_editmulti_localv6() break elif server_type == "2": genudpiranfive2sec_editmulti_localv6() break elif server_type == "3": genudpiranfive3sec_editmulti_localv6() break elif server_type == "4": genudpiranfive4sec_editmulti_localv6() break elif server_type == "5": genudpiranfive5sec_editmulti_localv6() break elif server_type == "6": genudpkharejonesec_editmulti_localmenuv6() break elif server_type == "0": os.system("clear") genudpsec_multiedit_localv6() break else: print("Invalid choice.") def genudpkharejonesec_editmulti_localmenuv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve V6 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharejone1sec_editmulti_localv6() break elif server_type == "2": genudpkharejone2sec_editmulti_localv6() break elif server_type == "3": genudpkharejone3sec_editmulti_localv6() break elif server_type == "4": genudpkharejone4sec_editmulti_localv6() break elif server_type == "5": genudpkharejone5sec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpsec_multiedit_localv6() break else: print("Invalid choice.") def genudpsec_edit_localkharej_multiv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharej1sec_editmulti_localv6() break elif server_type == "2": genudpkharej2sec_editmulti_localv6() break elif server_type == "3": genudpkharej3sec_editmulti_localv6() break elif server_type == "4": genudpkharej4sec_editmulti_localv6() break elif server_type == "5": genudpkharej5sec_editmulti_localv6() break elif server_type == "6": genudpiransec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpsec_multiedit_localv6() break else: print("Invalid choice.") def genudpiransec_editmulti_localv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V6 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpir1sec_editmulti_localv6() break elif server_type == "2": genudpir2sec_editmulti_localv6() break elif server_type == "3": genudpir3sec_editmulti_localv6() break elif server_type == "4": genudpir4sec_editmulti_localv6() break elif server_type == "5": genudpir5sec_editmulti_localv6() break elif server_type == "0": os.system("clear") genudpsec_multiedit_localv6() break else: print("Invalid choice.") # geneve ipsec menu def genudpsec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve + IPSEC UDP V4 Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": genudpsec_edit_localkharej_multi() break elif choice == "2": genudpsec_edit_localiran_multi() break elif choice == "3": clear() gen_multiedit_local() break else: print("Invalid choice.") def genudpsec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpiranfive1sec_editmulti_local() break elif server_type == "2": genudpiranfive2sec_editmulti_local() break elif server_type == "3": genudpiranfive3sec_editmulti_local() break elif server_type == "4": genudpiranfive4sec_editmulti_local() break elif server_type == "5": genudpiranfive5sec_editmulti_local() break elif server_type == "6": genudpkharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") genudpsec_multiedit_local() break else: print("Invalid choice.") def genudpkharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve V4 + IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharejone1sec_editmulti_local() break elif server_type == "2": genudpkharejone2sec_editmulti_local() break elif server_type == "3": genudpkharejone3sec_editmulti_local() break elif server_type == "4": genudpkharejone4sec_editmulti_local() break elif server_type == "5": genudpkharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") genudpsec_multiedit_local() break else: print("Invalid choice.") def genudpsec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpkharej1sec_editmulti_local() break elif server_type == "2": genudpkharej2sec_editmulti_local() break elif server_type == "3": genudpkharej3sec_editmulti_local() break elif server_type == "4": genudpkharej4sec_editmulti_local() break elif server_type == "5": genudpkharej5sec_editmulti_local() break elif server_type == "6": genudpiransec_editmulti_local() break elif server_type == "0": os.system("clear") genudpsec_multiedit_local() break else: print("Invalid choice.") def genudpiransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve V4 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genudpir1sec_editmulti_local() break elif server_type == "2": genudpir2sec_editmulti_local() break elif server_type == "3": genudpir3sec_editmulti_local() break elif server_type == "4": genudpir4sec_editmulti_local() break elif server_type == "5": genudpir5sec_editmulti_local() break elif server_type == "0": os.system("clear") genudpsec_multiedit_local() break else: print("Invalid choice.") def private_genmulti(name): try: with open(name, "r") as f: content = f.read() match_v4 = re.search( r"ip addr add (\d+\.\d+\.\d+\.\d+)/32 dev azumigen?", content ) match_v6 = re.search(r"ip addr add (\S+::\d+)/64 dev azumigen?", content) if match_v4: return match_v4.group(1) elif match_v6: return match_v6.group(1) else: print(f"\033[91mno private IP found\033[0m") except FileNotFoundError: print(f"file {name} doesn't exist") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def update_ipfile_gensec(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": if ":" in new_ip: new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) else: new_content = re.sub( r"ip addr add \d+\.\d+\.\d+\.\d+/32 dev azumigen?", f"ip addr add {new_ip}/32 dev azumigen", content, ) ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"ip route add \d+\.\d+\.\d+\.\d+/32 dev azumigen?", f"ip route add {counterpart_ip}/32 dev azumigen", new_content, ) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "ipsec": if ":" in new_ip: ip_parts = new_ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_ip}/64", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) new_content = re.sub( r"right=\S+", f"right={counterpart_ip}", new_content ) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", new_content ) else: ip_parts = new_ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" counterpart_ip = ".".join(ip_parts) new_content = re.sub( r"leftsubnet=\S+", f"leftsubnet={new_ip}/32", content ) new_content = re.sub(r"leftid=\S+", f"leftid={new_ip}", new_content) new_content = re.sub( r"right=\S+", f"right={counterpart_ip}", new_content ) new_content = re.sub( r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/32", new_content ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_secret(name, new_secret): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK "[^"]+"', f'PSK "{new_secret}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def get_current_private_ipsgen_multi1(): private_ip_geneve = private_genmulti("/etc/sys1.sh") return { "geneve": private_ip_geneve, } # changes def display_stuff_k1(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [1] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_i1(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_conf_geniran1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec1(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi1() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping1_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys1.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys1.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec1.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping1_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping1_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping1_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec_iran1(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi1() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping1_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys1.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys1.sh", remote_ip, update_type="remote") update_ipsec_conf_geniran1("/etc/ipsec1.conf", private_ip) update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen1" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping1_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping1_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping1_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir1sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej1sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 1 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 2 def get_current_private_ipsgen_multi2(): private_ip_geneve = private_genmulti("/etc/sys2.sh") return { "geneve": private_ip_geneve, } def display_stuff_k2(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [2] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_conf_geniran2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec2(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi2() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping2_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys2.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys2.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec1.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping2_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping2_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping2_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec_iran2(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi2() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping2_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys2.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys2.sh", remote_ip, update_type="remote") update_ipsec_conf_geniran2("/etc/ipsec1.conf", private_ip) update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen2" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping2_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping2_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping2_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir2sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k2(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej2sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 2 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 3 def get_current_private_ipsgen_multi3(): private_ip_geneve = private_genmulti("/etc/sys3.sh") return { "geneve": private_ip_geneve, } def display_stuff_k3(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [3] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_conf_geniran3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec3(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi3() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping3_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys3.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys3.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec1.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping3_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping3_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping3_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec_iran3(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi3() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping3_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys3.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys3.sh", remote_ip, update_type="remote") update_ipsec_conf_geniran2("/etc/ipsec1.conf", private_ip) update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen3" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping3_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping3_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping3_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir3sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k3(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej3sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 3 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 4 def get_current_private_ipsgen_multi4(): private_ip_geneve = private_genmulti("/etc/sys4.sh") return { "geneve": private_ip_geneve, } def display_stuff_k4(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [4] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_conf_geniran4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec4(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi4() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping4_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys4.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys4.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec1.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping4_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping4_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping4_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec_iran4(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi4() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping4_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys4.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys4.sh", remote_ip, update_type="remote") update_ipsec_conf_geniran4("/etc/ipsec1.conf", private_ip) update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen4" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping4_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping4_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping4_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir4sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k4(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej4sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 4 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 5 def get_current_private_ipsgen_multi5(): private_ip_geneve = private_genmulti("/etc/sys5.sh") return { "geneve": private_ip_geneve, } def display_stuff_k5(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej [5] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def update_ipsec_conf_geniran5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec5(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi5() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping5_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys5.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys5.sh", remote_ip, update_type="remote") update_ipfile_gensec("/etc/ipsec1.conf", private_ip, update_type="ipsec") update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping5_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping5_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping5_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gensec_iran5(private_ip, remote_ip, ipsec_secret): try: current_ips = get_current_private_ipsgen_multi5() current_ip = current_ips.get("geneve") if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(private_ip) opposite_private_ip = wtb_opposite_ipgen(private_ip) update_pingfilegen("/etc/ping5_sys.sh", opposite_private_ip) update_ipfile_gensec("/etc/sys5.sh", private_ip, update_type="private") update_ipfile_gensec("/etc/sys5.sh", remote_ip, update_type="remote") update_ipsec_conf_geniran5("/etc/ipsec1.conf", private_ip) update_ipsec_secret("/etc/ipsec.secrets", ipsec_secret) try: interface = "azumigen5" subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("interface already exists, don't mind this") else: result.check_returncode() display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run( ["sudo", "systemctl", "restart", "ping5_gen.service"], check=True ) except subprocess.CalledProcessError as e: if "Unit ping5_gen.service not found" in (e.stderr or ""): print( "\033[91mFailed to restart ping_gen.service: ping5_gen.service not found.\033[0m" ) else: raise subprocess.run(["sudo", "systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in (result.stdout or ""): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], check=True ) else: print( "\033[91mstrong-azumi service not found, don't mind this error.\033[0m" ) except subprocess.CalledProcessError as e: print(f"\033[91merror applying network stuff: geneve udp v4 error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def genudpir5sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k5(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej5sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 5 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # v6 5 kharej 1 iran def genudpir1sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve V6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej1sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 1 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpir2sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k2(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej2sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 2 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpir3sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k3(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej3sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 3 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpir4sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k4(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej4sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 4 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpir5sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_k5(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 [5]Kharej [1]IRAN\033[93m IRAN Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharej5sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_i1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve V6 + IPSEC [5]Kharej [1]IRAN\033[93m Kharej Server 5 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def display_stuff_kharej(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mKharej Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def display_stuff_iran1(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [1] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpkharejone1sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive1sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 1 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 2 def display_stuff_iran2(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [2] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpkharejone2sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran2(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive2sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 2 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 3 def display_stuff_iran3(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [3] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpkharejone3sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran3(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive3sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 3 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 4 def display_stuff_iran4(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [4] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpkharejone4sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran4(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive4sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 4 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # 5 def display_stuff_iran5(remote_ip, private_ip, ipsec_secret): lines = [ f"\033[93mTitle: Geneve Configuration\033[0m", f"\033[97m──────────────────────────────────────\033[0m", f"\033[92mIRAN [5] Public IP: \033[97m{remote_ip}\033[0m", f"\033[93mGeneve Private IP: \033[97m{private_ip}\033[0m", f"\033[94mIPSec key: \033[97m{ipsec_secret}\033[0m", ] box_width = 50 print("\033[93m╭" + "─" * (box_width - 2) + "╮\033[0m") for line in lines: print(f"\033[93m {line:<{box_width - 4}} \033[0m") print("\033[93m╰" + "─" * (box_width - 2) + "╯\033[0m") def genudpkharejone5sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran5(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive5sec_editmulti_local(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 5 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV4 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV4 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") # v6 1kharej 5 iran #1 def genudpkharejone1sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran1(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive1sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys1.sh") private_ip_private = private_genmulti("/etc/sys1.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 1 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec1( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone2sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran2(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi2(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive2sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys2.sh") private_ip_private = private_genmulti("/etc/sys2.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 2 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec2( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone3sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran3(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi3(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive3sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys3.sh") private_ip_private = private_genmulti("/etc/sys3.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 3 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec3( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def ipsec_secret(name): try: with open(name, "r") as f: content = f.read() match = re.search(r'PSK "([^"]+)"', content) if match: return match.group(1) else: print("\033[91mno IPSec secret found\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") return None def genudpkharejone4sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran4(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi4(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive4sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys4.sh") private_ip_private = private_genmulti("/etc/sys4.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 4 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec4( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpkharejone5sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_iran5(remote_ip_private, private_ip_private, ipsec_secret_private) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve [1]Kharej [5]IRAN\033[93m Kharej Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5]\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec_iran5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip_multi5(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def genudpiranfive5sec_editmulti_localv6(): remote_ip_private = remote_ip("/etc/sys5.sh") private_ip_private = private_genmulti("/etc/sys5.sh") ipsec_secret_private = ipsec_secret("/etc/ipsec.secrets") if not remote_ip_private or not private_ip_private or not ipsec_secret_private: print("Couldn't retrieve IP addresses or IPSec secret from files") return while True: os.system("clear") display_stuff_kharej( remote_ip_private, private_ip_private, ipsec_secret_private ) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve + IPSEC [5]Kharej [1]IRAN\033[93m IRAN Server 5 Menu\033[0m" ) print( '\033[92m "-"\033[93m═════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej\033[92m Public IP\033[0m") print("2. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6 \033[0m") print("3. \033[93mChange IPSec Secret Key\033[0m") print("4. \033[96mSave Stuff\033[0m") print("0. \033[97mback to local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "2": new_ip = input( "\033[93mEnter New Private IPV6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: old_ip = private_ip_private private_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "3": new_secret = input("\033[93mEnter new IPSec Secret Key :\033[0m ") if new_secret: ipsec_secret_private = new_secret else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "4": save_stuff_gensec5( private_ip_private, remote_ip_private, ipsec_secret_private ) update_ipsec_ip(private_ip_private) break elif choice == "0": clear() multi_edit_local() break else: print("Please select a valid option.") def wtb_opposite_ipgen(ip): if ":" in ip: # IPv6 ip_parts = ip.split(":") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ":".join(ip_parts) else: # IPv4 ip_parts = ip.split(".") ip_parts[-1] = "1" if ip_parts[-1] == "2" else "2" return ".".join(ip_parts) def update_pingfilegen(name, new_ip): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{new_ip}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengre_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPSEC\033[0m") print("2. \033[93mWith IPSEC\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengrenosec_multiedit_local() break elif choice == "2": gengresec_multiedit_local() break elif choice == "3": clear() multi_edit_local() break else: print("Invalid choice.") def gengrenosec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve Gre6 Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengrenosec_edit_localkharej_multi() break elif choice == "2": gengrenosec_edit_localiran_multi() break elif choice == "3": clear() gengre_multiedit_local() break else: print("Invalid choice.") def gengrenosec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengreiranfive1nosec_editmulti_local() break elif server_type == "2": gengreiranfive2nosec_editmulti_local() break elif server_type == "3": gengreiranfive3nosec_editmulti_local() break elif server_type == "4": gengreiranfive4nosec_editmulti_local() break elif server_type == "5": gengreiranfive5nosec_editmulti_local() break elif server_type == "6": gengrekharejonenosec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gengrenosec_multiedit_local() break else: print("Invalid choice.") def gengrekharejonenosec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve GRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengrekharejone1nosec_editmulti_local() break elif server_type == "2": gengrekharejone2nosec_editmulti_local() break elif server_type == "3": gengrekharejone3nosec_editmulti_local() break elif server_type == "4": gengrekharejone4nosec_editmulti_local() break elif server_type == "5": gengrekharejone5nosec_editmulti_local() break elif server_type == "0": os.system("clear") gengrenosec_multiedit_local() break else: print("Invalid choice.") def gengrenosec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengrekharej1nosec_editmulti_local() break elif server_type == "2": gengrekharej2nosec_editmulti_local() break elif server_type == "3": gengrekharej3nosec_editmulti_local() break elif server_type == "4": gengrekharej4nosec_editmulti_local() break elif server_type == "5": gengrekharej5nosec_editmulti_local() break elif server_type == "6": gengreirannosec_editmulti_local() break elif server_type == "0": os.system("clear") gengrenosec_multiedit_local() break else: print("Invalid choice.") def gengreirannosec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengreir1nosec_editmulti_local() break elif server_type == "2": gengreir2nosec_editmulti_local() break elif server_type == "3": gengreir3nosec_editmulti_local() break elif server_type == "4": gengreir4nosec_editmulti_local() break elif server_type == "5": gengreir5nosec_editmulti_local() break elif server_type == "0": os.system("clear") gengrenosec_multiedit_local() break else: print("Invalid choice.") def update_pingfile_gengrenosec(name, ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "geneve": new_content = re.sub(r"remote \S+", f"remote {ip}", content) elif update_type == "geneve_opposite": opposite_ip = wtb_opposite_ip_gengrenosec(ip) new_content = re.sub(r"remote \S+", f"remote {opposite_ip}", content) elif update_type == "ping_ip": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_v6": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_sys_opposite": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) else: print("\033[91mInvalid update type for pingfile\033[0m") return with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ip_gengrenosec(ip): ip_parts = ip.split(":") if ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" return ":".join(ip_parts) def update_ipsecsecret(name, new_key): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK ".*"', f'PSK "{new_key}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") # server 1 def get_current_private_ipsgregen1(): private_ip_private = private_ip1("/etc/private1.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegengre_nosec1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec1( "/etc/gre61.sh", new_ip, update_type="gre6_local" ) update_ipfilegengre_nosec1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gengrenosec1( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen1() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip1.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec1( "/etc/gre61.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec1("/etc/gre61.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec1( "/etc/sys1.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping1_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping1_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec1( "/etc/sys1.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v61.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec1( "/etc/private1.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec1( "/etc/private1.sh", local_ip, update_type="local" ) update_ipfilegengre_nosec1( "/etc/private1.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig61" if is_gre6 else "azumi1" if is_geneve: interface = "azumigen1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" if is_geneve: script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v61"], check=True) display_checkmark("\033[92mping_v61 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v61 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v61\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping1_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping1_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping1_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) display_checkmark("\033[92mping_ip1 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip1 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengreir1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [1] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej [1] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 2 def get_current_private_ipsgregen2(): private_ip_private = private_ip1("/etc/private2.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegengre_nosec2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec2( "/etc/gre62.sh", new_ip, update_type="gre6_local" ) update_ipfilegengre_nosec2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gengrenosec2( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen2() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip2.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec2( "/etc/gre62.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec2("/etc/gre62.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec2( "/etc/sys2.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping2_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping2_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec2( "/etc/sys2.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v62.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec2( "/etc/private2.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec2( "/etc/private2.sh", local_ip, update_type="local" ) update_ipfilegengre_nosec2( "/etc/private2.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig62" if is_gre6 else "azumi2" if is_geneve: interface = "azumigen2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" if is_geneve: script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v62"], check=True) display_checkmark("\033[92mping_v62 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v62 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v62\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping2_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping2_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping2_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) display_checkmark("\033[92mping_ip2 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip2 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip2\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengreir2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [2] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej [2] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 3 def get_current_private_ipsgregen3(): private_ip_private = private_ip1("/etc/private3.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegengre_nosec3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec3( "/etc/gre63.sh", new_ip, update_type="gre6_local" ) update_ipfilegengre_nosec3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gengrenosec3( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen3() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip3.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec3( "/etc/gre63.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec3("/etc/gre63.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec3( "/etc/sys3.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping3_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping3_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec3( "/etc/sys3.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v63.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec3( "/etc/private3.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec3( "/etc/private3.sh", local_ip, update_type="local" ) update_ipfilegengre_nosec3( "/etc/private3.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig63" if is_gre6 else "azumi3" if is_geneve: interface = "azumigen3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" if is_geneve: script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v63"], check=True) display_checkmark("\033[92mping_v63 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v63 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v63\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping3_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping3_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping3_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) display_checkmark("\033[92mping_ip3 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip3 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip3\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengreir3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [3] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej [3] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 4 def get_current_private_ipsgregen4(): private_ip_private = private_ip1("/etc/private4.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegengre_nosec4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec4( "/etc/gre64.sh", new_ip, update_type="gre6_local" ) update_ipfilegengre_nosec4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gengrenosec4( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen4() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip4.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec4( "/etc/gre64.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec4("/etc/gre64.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec4( "/etc/sys4.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping4_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping4_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec4( "/etc/sys4.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v64.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec4( "/etc/private4.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec4( "/etc/private4.sh", local_ip, update_type="local" ) update_ipfilegengre_nosec4( "/etc/private4.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig64" if is_gre6 else "azumi4" if is_geneve: interface = "azumigen4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" if is_geneve: script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v64"], check=True) display_checkmark("\033[92mping_v64 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v64 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v64\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping4_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping4_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping4_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) display_checkmark("\033[92mping_ip4 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip4 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip4\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengreir4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [4] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej [4] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 5 def get_current_private_ipsgregen5(): private_ip_private = private_ip1("/etc/private5.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegengre_nosec5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegengre_nosec5( "/etc/gre65.sh", new_ip, update_type="gre6_local" ) update_ipfilegengre_nosec5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ip_gengrenosec(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gengrenosec5( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen5() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ip_gengrenosec(new_private_ip) try: if is_gre6: update_pingfile_gengrenosec( "/etc/ping_ip5.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegengre_nosec5( "/etc/gre65.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec5("/etc/gre65.sh", remote_ip, update_type="remote") update_ipfilegengre_nosec5( "/etc/sys5.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfile_gengrenosec( "/etc/ping5_sys.sh", remote_ip, update_type="geneve" ) update_pingfile_gengrenosec( "/etc/ping5_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegengre_nosec5( "/etc/sys5.sh", new_private_ip, update_type="geneve_private" ) update_pingfile_gengrenosec( "/etc/ping5_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) else: update_pingfile_gengrenosec( "/etc/ping_v65.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegengre_nosec5( "/etc/private5.sh", new_private_ip, update_type="private" ) update_ipfilegengre_nosec5( "/etc/private5.sh", local_ip, update_type="local" ) update_ipfilegengre_nosec5( "/etc/private5.sh", remote_ip, update_type="remote" ) update_ipfilegengre_nosec5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfile_gengrenosec( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig65" if is_gre6 else "azumi5" if is_geneve: interface = "azumigen5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" if is_geneve: script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v65"], check=True) display_checkmark("\033[92mping_v65 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v65 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v65\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping5_gen"], check=True) display_checkmark( "\033[92mSystem services reloaded and restarted successfully!\033[0m" ) except subprocess.CalledProcessError as e: if "Unit ping5_gen.service not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping5_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) display_checkmark("\033[92mping_ip5 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip4 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip5\033[0m") display_checkmark( f"\033[92mChanges saved and {interface} interface updated successfully!\033[0m" ) except subprocess.CalledProcessError: print("\033[91merror in applying network changes: don't mind this error\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def gengreir5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [5] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej [5] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # 5 iran 1 kharej gen gre6 # server 1 def gengrekharejone1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive1nosec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec1( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec1( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec1( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 2 def gengrekharejone2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive2nosec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec2( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec2( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec2( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 3 def gengrekharejone3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive3nosec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec3( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec3( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec3( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 4 def gengrekharejone4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive4nosec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec4( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec4( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec4( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 5 def gengrekharejone5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ip_gengrenosec(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive5nosec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": save_stuff_gengrenosec5( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gengrenosec5( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gengrenosec5( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengresec_multiedit_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit local\033[93m Geneve Gre6 IPSEC Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": gengresec_edit_localkharej_multi() break elif choice == "2": gengresec_edit_localiran_multi() break elif choice == "3": clear() gengre_multiedit_local() break else: print("Invalid choice.") def gengresec_edit_localiran_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengreiranfive1sec_editmulti_local() break elif server_type == "2": gengreiranfive2sec_editmulti_local() break elif server_type == "3": gengreiranfive3sec_editmulti_local() break elif server_type == "4": gengreiranfive4sec_editmulti_local() break elif server_type == "5": gengreiranfive5sec_editmulti_local() break elif server_type == "6": gengrekharejonesec_editmulti_localmenu() break elif server_type == "0": os.system("clear") gengresec_multiedit_local() break else: print("Invalid choice.") def gengrekharejonesec_editmulti_localmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGenve GRE6 IPSEC \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is Kharej menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengrekharejone1sec_editmulti_local() break elif server_type == "2": gengrekharejone2sec_editmulti_local() break elif server_type == "3": gengrekharejone3sec_editmulti_local() break elif server_type == "4": gengrekharejone4sec_editmulti_local() break elif server_type == "5": gengrekharejone5sec_editmulti_local() break elif server_type == "0": os.system("clear") gengresec_multiedit_local() break else: print("Invalid choice.") def gengresec_edit_localkharej_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN Menu\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengrekharej1sec_editmulti_local() break elif server_type == "2": gengrekharej2sec_editmulti_local() break elif server_type == "3": gengrekharej3sec_editmulti_local() break elif server_type == "4": gengrekharej4sec_editmulti_local() break elif server_type == "5": gengrekharej5sec_editmulti_local() break elif server_type == "6": gengreiransec_editmulti_local() break elif server_type == "0": os.system("clear") gengresec_multiedit_local() break else: print("Invalid choice.") def gengreiransec_editmulti_local(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve GRE6 IPSEC \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN menu:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengreir1sec_editmulti_local() break elif server_type == "2": gengreir2sec_editmulti_local() break elif server_type == "3": gengreir3sec_editmulti_local() break elif server_type == "4": gengreir4sec_editmulti_local() break elif server_type == "5": gengreir5sec_editmulti_local() break elif server_type == "0": os.system("clear") gengresec_multiedit_local() break else: print("Invalid choice.") def update_pingfilegregen(name, ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "geneve": new_content = re.sub(r"remote \S+", f"remote {ip}", content) elif update_type == "geneve_opposite": opposite_ip = wtb_opposite_ipgregen(ip) new_content = re.sub(r"remote \S+", f"remote {opposite_ip}", content) elif update_type == "ping_ip": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_v6": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) elif update_type == "ping_sys_opposite": new_content = re.sub(r'ip_address="[^"]+"', f'ip_address="{ip}"', content) else: print("\033[91mInvalid update type for pingfile\033[0m") return with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def wtb_opposite_ipgregen(ip): ip_parts = ip.split(":") if ip.endswith(":1"): ip_parts[-1] = "2" else: ip_parts[-1] = "1" return ":".join(ip_parts) def display_ipsecsecretgengre(secret_key): print(f"\033[97m──────────────────────────────────────\033[0m") print(f"\033[93m IPsec Key: \033[97m{secret_key}\033[0m") print(f"\033[97m──────────────────────────────────────\033[0m") def update_ipsecsecret(name, new_key): try: with open(name, "r") as f: content = f.read() new_content = re.sub(r'PSK ".*"', f'PSK "{new_key}"', content) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_config_leftsubnet(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = [] for line in content: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_content.append(line) with open(name, "w") as f: f.writelines(new_content) print(f"\033[92mIPsec configuration updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mUnexpected error: {e}\033[0m") # server 1 def get_current_private_ipsgregen1(): private_ip_private = private_ip1("/etc/private1.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen1(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen1("/etc/gre61.sh", new_ip, update_type="gre6_local") update_ipfilegregen1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_confgengre1(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve1": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve1' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve1' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gregen1_iran( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen1() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip1.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen1("/etc/gre61.sh", new_private_ip, update_type="private") update_ipfilegregen1("/etc/gre61.sh", remote_ip, update_type="remote") update_ipfilegregen1( "/etc/sys1.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping1_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen1( "/etc/sys1.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre1("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v61.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen1( "/etc/private1.sh", new_private_ip, update_type="private" ) update_ipfilegregen1("/etc/private1.sh", local_ip, update_type="local") update_ipfilegregen1("/etc/private1.sh", remote_ip, update_type="remote") update_ipfilegregen1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig61" if is_gre6 else "azumi1" if is_geneve: interface = "azumigen1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" if is_geneve: script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v61"], check=True) print("\033[92m✔ ping_v61 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v61 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v61\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping1_gen"], check=True) print("\033[92m✔ ping1_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping1_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) print("\033[92m✔ ping_ip1 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip1 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip1\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def save_stuff_gregen1_kharej( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen1() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip1.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen1("/etc/gre61.sh", new_private_ip, update_type="private") update_ipfilegregen1("/etc/gre61.sh", remote_ip, update_type="remote") update_ipfilegregen1( "/etc/sys1.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping1_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen1( "/etc/sys1.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_config_leftsubnet("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v61.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen1( "/etc/private1.sh", new_private_ip, update_type="private" ) update_ipfilegregen1("/etc/private1.sh", local_ip, update_type="local") update_ipfilegregen1("/etc/private1.sh", remote_ip, update_type="remote") update_ipfilegregen1( "/etc/gre61.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping1_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig61" if is_gre6 else "azumi1" if is_geneve: interface = "azumigen1" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre61.sh" if is_gre6 else "/etc/private1.sh" if is_geneve: script = "/etc/sys1.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v61"], check=True) print("\033[92m✔ ping_v61 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v61 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v61\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping1_gen"], check=True) print("\033[92m✔ ping1_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping1_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip1"], check=True) print("\033[92m✔ ping_ip1 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip1 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip1\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def gengreir1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [1] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen1_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen1_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej [1] Menu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [1] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen1_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [1]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen1_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen1_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen1_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server 2 def get_current_private_ipsgregen2(): private_ip_private = private_ip1("/etc/private2.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen2(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen2("/etc/gre62.sh", new_ip, update_type="gre6_local") update_ipfilegregen2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_confgengre2(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve2": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve2' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve2' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gregen2_iran( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen2() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip2.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen2("/etc/gre62.sh", new_private_ip, update_type="private") update_ipfilegregen2("/etc/gre62.sh", remote_ip, update_type="remote") update_ipfilegregen2( "/etc/sys2.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping2_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen2( "/etc/sys2.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre2("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v62.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen2( "/etc/private2.sh", new_private_ip, update_type="private" ) update_ipfilegregen2("/etc/private2.sh", local_ip, update_type="local") update_ipfilegregen2("/etc/private2.sh", remote_ip, update_type="remote") update_ipfilegregen2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig62" if is_gre6 else "azumi2" if is_geneve: interface = "azumigen2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" if is_geneve: script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v62"], check=True) print("\033[92m✔ ping_v62 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v62 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v62\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping2_gen"], check=True) print("\033[92m✔ ping2_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping2_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping2_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) print("\033[92m✔ ping_ip2 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip2 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip2\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def save_stuff_gregen2_kharej( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen2() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip2.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen2("/etc/gre62.sh", new_private_ip, update_type="private") update_ipfilegregen2("/etc/gre62.sh", remote_ip, update_type="remote") update_ipfilegregen2( "/etc/sys2.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping2_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen2( "/etc/sys2.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_config_leftsubnet("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v62.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen2( "/etc/private2.sh", new_private_ip, update_type="private" ) update_ipfilegregen2("/etc/private2.sh", local_ip, update_type="local") update_ipfilegregen2("/etc/private2.sh", remote_ip, update_type="remote") update_ipfilegregen2( "/etc/gre62.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping2_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig62" if is_gre6 else "azumi2" if is_geneve: interface = "azumigen2" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre62.sh" if is_gre6 else "/etc/private2.sh" if is_geneve: script = "/etc/sys2.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v62"], check=True) print("\033[92m✔ ping_v62 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v62 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v62\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping2_gen"], check=True) print("\033[92m✔ ping2_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping2_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping2_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip2"], check=True) print("\033[92m✔ ping_ip2 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip2 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip2\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def gengreir2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [2] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen2_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen2_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi2(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej [2] Menu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [2] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen2_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [2]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen2_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen2_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen2_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server3 def get_current_private_ipsgregen3(): private_ip_private = private_ip1("/etc/private3.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen3(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen3("/etc/gre63.sh", new_ip, update_type="gre6_local") update_ipfilegregen3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_confgengre3(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve3": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve3' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve3' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gregen3_iran( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen3() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip3.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen3("/etc/gre63.sh", new_private_ip, update_type="private") update_ipfilegregen3("/etc/gre63.sh", remote_ip, update_type="remote") update_ipfilegregen3( "/etc/sys3.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping3_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen3( "/etc/sys3.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre3("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v63.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen3( "/etc/private3.sh", new_private_ip, update_type="private" ) update_ipfilegregen3("/etc/private3.sh", local_ip, update_type="local") update_ipfilegregen3("/etc/private3.sh", remote_ip, update_type="remote") update_ipfilegregen3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig63" if is_gre6 else "azumi3" if is_geneve: interface = "azumigen3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" if is_geneve: script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v63"], check=True) print("\033[92m✔ ping_v63 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v63 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v63\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping3_gen"], check=True) print("\033[92m✔ ping3_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping3_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping3_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) print("\033[92m✔ ping_ip3 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip3 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip3\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def save_stuff_gregen3_kharej( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen3() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip3.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen3("/etc/gre63.sh", new_private_ip, update_type="private") update_ipfilegregen3("/etc/gre63.sh", remote_ip, update_type="remote") update_ipfilegregen3( "/etc/sys3.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping3_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen3( "/etc/sys3.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_config_leftsubnet("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v63.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen3( "/etc/private3.sh", new_private_ip, update_type="private" ) update_ipfilegregen3("/etc/private3.sh", local_ip, update_type="local") update_ipfilegregen3("/etc/private3.sh", remote_ip, update_type="remote") update_ipfilegregen3( "/etc/gre63.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping3_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig63" if is_gre6 else "azumi3" if is_geneve: interface = "azumigen3" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre63.sh" if is_gre6 else "/etc/private3.sh" if is_geneve: script = "/etc/sys3.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v63"], check=True) print("\033[92m✔ ping_v63 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v63 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v63\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping3_gen"], check=True) print("\033[92m✔ ping3_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping3_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping3_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip3"], check=True) print("\033[92m✔ ping_ip3 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip3 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip3\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def gengreir3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [3] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen3_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen3_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi3(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej [3] Menu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [3] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen3_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [3]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen3_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen3_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen3_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server4 def get_current_private_ipsgregen4(): private_ip_private = private_ip1("/etc/private4.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen4(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen4("/etc/gre64.sh", new_ip, update_type="gre6_local") update_ipfilegregen4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_confgengre4(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve4": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve4' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve4' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gregen4_iran( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen4() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip4.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen4("/etc/gre64.sh", new_private_ip, update_type="private") update_ipfilegregen4("/etc/gre64.sh", remote_ip, update_type="remote") update_ipfilegregen4( "/etc/sys4.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping4_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen4( "/etc/sys4.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre4("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v64.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen4( "/etc/private4.sh", new_private_ip, update_type="private" ) update_ipfilegregen4("/etc/private4.sh", local_ip, update_type="local") update_ipfilegregen4("/etc/private4.sh", remote_ip, update_type="remote") update_ipfilegregen4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig64" if is_gre6 else "azumi4" if is_geneve: interface = "azumigen4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" if is_geneve: script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v64"], check=True) print("\033[92m✔ ping_v64 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v64 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v64\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping4_gen"], check=True) print("\033[92m✔ ping4_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping4_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping4_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) print("\033[92m✔ ping_ip4 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip4 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip4\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def save_stuff_gregen4_kharej( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen4() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip4.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen4("/etc/gre64.sh", new_private_ip, update_type="private") update_ipfilegregen4("/etc/gre64.sh", remote_ip, update_type="remote") update_ipfilegregen4( "/etc/sys4.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping4_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen4( "/etc/sys4.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_config_leftsubnet("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v64.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen4( "/etc/private4.sh", new_private_ip, update_type="private" ) update_ipfilegregen4("/etc/private4.sh", local_ip, update_type="local") update_ipfilegregen4("/etc/private4.sh", remote_ip, update_type="remote") update_ipfilegregen4( "/etc/gre64.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping4_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig64" if is_gre6 else "azumi4" if is_geneve: interface = "azumigen4" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre64.sh" if is_gre6 else "/etc/private4.sh" if is_geneve: script = "/etc/sys4.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v64"], check=True) print("\033[92m✔ ping_v64 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v64 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v64\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping4_gen"], check=True) print("\033[92m✔ ping4_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping4_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping4_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip4"], check=True) print("\033[92m✔ ping_ip4 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip4 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip4\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def gengreir4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [4] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen4_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen4_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi4(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej [4] Menu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [4] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local single menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen4_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [4]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen4_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen4_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen4_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # server5 def get_current_private_ipsgregen5(): private_ip_private = private_ip1("/etc/private5.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") return { "private": private_ip_private, "gre6": private_ip_gre6, "geneve": private_ip_geneve, } def update_ipfilegregen5(name, new_ip, update_type): try: with open(name, "r") as f: content = f.read() if update_type == "private": new_content = re.sub( r"ip (-6 )?addr add [^ ]+/64 dev azumi?", f"ip -6 addr add {new_ip}/64 dev azumi", content, ) ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_content = re.sub( r"ip (-6 )?route add [^ ]+/64 dev azumi?", f"ip -6 route add {counterpart_ip}/64 dev azumi", new_content, ) update_ipfilegregen5("/etc/gre65.sh", new_ip, update_type="gre6_local") update_ipfilegregen5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) elif update_type == "local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "gre6_local": new_content = re.sub(r"local \S+", f"local {new_ip}", content) elif update_type == "gre6_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_remote": new_content = re.sub(r"remote \S+", f"remote {new_ip}", content) elif update_type == "geneve_private": new_content = re.sub( r"ip addr add \S+/64 dev azumigen?", f"ip addr add {new_ip}/64 dev azumigen", content, ) counterpart_ip = wtb_opposite_ipgregen(new_ip) new_content = re.sub( r"ip route add \S+/64 dev azumigen?", f"ip route add {counterpart_ip}/64 dev azumigen", new_content, ) with open(name, "w") as f: f.write(new_content) except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def update_ipsec_confgengre5(name, new_private_ip): try: with open(name, "r") as f: content = f.readlines() start_idx, end_idx = None, None for i, line in enumerate(content): if line.strip() == "conn Geneve5": start_idx = i elif start_idx is not None and line.strip().startswith("conn "): end_idx = i break if start_idx is None: print("\033[91m'conn Geneve5' section not found\033[0m") return if end_idx is None: end_idx = len(content) section = content[start_idx:end_idx] ip_parts = new_private_ip.split(":") if new_private_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) new_section = [] for line in section: line = re.sub(r"leftsubnet=\S+", f"leftsubnet={new_private_ip}/64", line) line = re.sub(r"leftid=\S+", f"leftid={new_private_ip}", line) line = re.sub(r"right=\S+", f"right={counterpart_ip}", line) line = re.sub(r"rightsubnet=\S+", f"rightsubnet={counterpart_ip}/64", line) new_section.append(line) new_content = content[:start_idx] + new_section + content[end_idx:] with open(name, "w") as f: f.writelines(new_content) print(f"\033[92m'conn Geneve5' section updated successfully\033[0m") except FileNotFoundError: print("\033[91mfile not found\033[0m") except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") def save_stuff_gregen5_iran( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen5() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip5.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen5("/etc/gre65.sh", new_private_ip, update_type="private") update_ipfilegregen5("/etc/gre65.sh", remote_ip, update_type="remote") update_ipfilegregen5( "/etc/sys5.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping5_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen5( "/etc/sys5.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_confgengre5("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v65.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen5( "/etc/private5.sh", new_private_ip, update_type="private" ) update_ipfilegregen5("/etc/private5.sh", local_ip, update_type="local") update_ipfilegregen5("/etc/private5.sh", remote_ip, update_type="remote") update_ipfilegregen5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig65" if is_gre6 else "azumi5" if is_geneve: interface = "azumigen5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" if is_geneve: script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v65"], check=True) print("\033[92m✔ ping_v65 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v65 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v65\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping5_gen"], check=True) print("\033[92m✔ ping5_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping5_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping5_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) print("\033[92m✔ ping_ip5 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip5 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip5\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def save_stuff_gregen5_kharej( new_private_ip, local_ip, remote_ip, is_gre6, is_geneve=False ): current_ips = get_current_private_ipsgregen5() if is_gre6: current_ip = current_ips["gre6"] elif is_geneve: current_ip = current_ips["geneve"] else: current_ip = current_ips["private"] if current_ip: delete_ufw_rules(current_ip) add_ufw_rules(new_private_ip) counterpart_ip = wtb_opposite_ipgregen(new_private_ip) try: if is_gre6: update_pingfilegregen( "/etc/ping_ip5.sh", counterpart_ip, update_type="ping_ip" ) update_ipfilegregen5("/etc/gre65.sh", new_private_ip, update_type="private") update_ipfilegregen5("/etc/gre65.sh", remote_ip, update_type="remote") update_ipfilegregen5( "/etc/sys5.sh", counterpart_ip, update_type="geneve_remote" ) update_pingfilegregen("/etc/ping5_sys.sh", remote_ip, update_type="geneve") update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="geneve_opposite" ) elif is_geneve: update_ipfilegregen5( "/etc/sys5.sh", new_private_ip, update_type="geneve_private" ) update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) update_ipsec_config_leftsubnet("/etc/ipsec1.conf", new_private_ip) else: update_pingfilegregen( "/etc/ping_v65.sh", counterpart_ip, update_type="ping_v6" ) update_ipfilegregen5( "/etc/private5.sh", new_private_ip, update_type="private" ) update_ipfilegregen5("/etc/private5.sh", local_ip, update_type="local") update_ipfilegregen5("/etc/private5.sh", remote_ip, update_type="remote") update_ipfilegregen5( "/etc/gre65.sh", counterpart_ip, update_type="gre6_remote" ) update_pingfilegregen( "/etc/ping5_sys.sh", counterpart_ip, update_type="ping_sys_opposite" ) interface = "azumig65" if is_gre6 else "azumi5" if is_geneve: interface = "azumigen5" try: subprocess.run(["ip", "link", "set", "dev", interface, "down"], check=True) subprocess.run(["ip", "link", "delete", interface], check=True) except subprocess.CalledProcessError: print("\033[91merror bringing interface down or deleting it\033[0m") script = "/etc/gre65.sh" if is_gre6 else "/etc/private5.sh" if is_geneve: script = "/etc/sys5.sh" result = subprocess.run(["/bin/bash", script], capture_output=True, text=True) if "RTNETLINK answers: File exists" in result.stderr: print("\033[91madditional ip already exists. Ignoring this error\033[0m") else: result.check_returncode() subprocess.run(["sudo", "systemctl", "daemon-reload"], check=True) try: subprocess.run(["systemctl", "restart", "ping_v65"], check=True) print("\033[92m✔ ping_v65 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_v65 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_v65\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping5_gen"], check=True) print("\033[92m✔ ping5_gen service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping5_gen not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping5_gen\033[0m") try: subprocess.run(["sudo", "systemctl", "restart", "ping_ip5"], check=True) print("\033[92m✔ ping_ip5 service restarted successfully!\033[0m") except subprocess.CalledProcessError as e: if "Unit ping_ip5 not found" in (e.stderr or ""): print("\033[91mcouldn't restart ping_ip5\033[0m") subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) result = subprocess.run( ["systemctl", "list-units", "--full", "--all", "strong-azumi1.service"], capture_output=True, text=True, ) if "strong-azumi1.service" in result.stdout: subprocess.run(["systemctl", "restart", "strong-azumi1"], check=True) else: print("\033[91mstrong service not found. don't mind this error\033[0m") except subprocess.CalledProcessError: print( "\033[91merror in applying network changes : gen gre related error\033[0m" ) except Exception as e: print(f"\033[91mout of ordinary error: {e}\033[0m") print( f"\033[92m✔ Changes saved and {interface} interface updated successfully!\033[0m" ) def gengreir5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiran5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej [5] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen5_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen5_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi5(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengrekharej5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharej5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej [5] Menu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej [5] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen5_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input( "\033[93mEnter \033[92mKharej [5]\033[93m Public IP :\033[0m " ) if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen5_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen5_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen5_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran5 kharej 1 def gengrekharejone1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [1] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen1_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen1_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen1_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen1_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive1sec_editmulti_local(): local_ip_private = local_ip("/etc/private1.sh") remote_ip_private = remote_ip("/etc/private1.sh") private_ip_private = private_ip1("/etc/private1.sh") local_ip_gre6 = local_ip("/etc/gre61.sh") remote_ip_gre6 = remote_ip("/etc/gre61.sh") private_ip_gre6 = private_gre6multi("/etc/gre61.sh") remote_ip_geneve = remote_ip("/etc/sys1.sh") private_ip_geneve = private_genmulti("/etc/sys1.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive1( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN [1] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [1] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen1_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [1]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen1_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen1_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen1_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran5 kharej 2 def gengrekharejone2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [2] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen2_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen2_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen2_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen2_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi2(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive2sec_editmulti_local(): local_ip_private = local_ip("/etc/private2.sh") remote_ip_private = remote_ip("/etc/private2.sh") private_ip_private = private_ip1("/etc/private2.sh") local_ip_gre6 = local_ip("/etc/gre62.sh") remote_ip_gre6 = remote_ip("/etc/gre62.sh") private_ip_gre6 = private_gre6multi("/etc/gre62.sh") remote_ip_geneve = remote_ip("/etc/sys2.sh") private_ip_geneve = private_genmulti("/etc/sys2.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive2( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN [2] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [2] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen2_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [2]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen2_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen2_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen2_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran5 kharej 3 def gengrekharejone3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [3] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen3_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen3_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen3_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen3_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi3(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive3sec_editmulti_local(): local_ip_private = local_ip("/etc/private3.sh") remote_ip_private = remote_ip("/etc/private3.sh") private_ip_private = private_ip1("/etc/private3.sh") local_ip_gre6 = local_ip("/etc/gre63.sh") remote_ip_gre6 = remote_ip("/etc/gre63.sh") private_ip_gre6 = private_gre6multi("/etc/gre63.sh") remote_ip_geneve = remote_ip("/etc/sys3.sh") private_ip_geneve = private_genmulti("/etc/sys3.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive3( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN [3] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [3] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen3_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [3]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen3_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen3_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen3_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran5 kharej 4 def gengrekharejone4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [4] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen4_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen4_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen4_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen4_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi4(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive4sec_editmulti_local(): local_ip_private = local_ip("/etc/private4.sh") remote_ip_private = remote_ip("/etc/private4.sh") private_ip_private = private_ip1("/etc/private4.sh") local_ip_gre6 = local_ip("/etc/gre64.sh") remote_ip_gre6 = remote_ip("/etc/gre64.sh") private_ip_gre6 = private_gre6multi("/etc/gre64.sh") remote_ip_geneve = remote_ip("/etc/sys4.sh") private_ip_geneve = private_genmulti("/etc/sys4.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive4( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN [4] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [4] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen4_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [4]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen4_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen4_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen4_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") # iran5 kharej 5 def gengrekharejone5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privatekharejone5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m Kharej Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mKharej \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mIRAN [5] \033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen5_iran( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen5_iran( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen5_iran( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen5_iran( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip_multi5(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") def gengreiranfive5sec_editmulti_local(): local_ip_private = local_ip("/etc/private5.sh") remote_ip_private = remote_ip("/etc/private5.sh") private_ip_private = private_ip1("/etc/private5.sh") local_ip_gre6 = local_ip("/etc/gre65.sh") remote_ip_gre6 = remote_ip("/etc/gre65.sh") private_ip_gre6 = private_gre6multi("/etc/gre65.sh") remote_ip_geneve = remote_ip("/etc/sys5.sh") private_ip_geneve = private_genmulti("/etc/sys5.sh") ipsecsecret = get_ipsecsecret("/etc/ipsec.secrets") if not local_ip_private or not remote_ip_private or not private_ip_private: print("couldn't retrieve IP addresses from private file") if not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6: print("couldn't retrieve IP addresses from gre6 file") if not remote_ip_geneve or not private_ip_geneve: print("couldn't retrieve IP addresses from geneve file") if ( not local_ip_private or not remote_ip_private or not private_ip_private or not local_ip_gre6 or not remote_ip_gre6 or not private_ip_gre6 or not remote_ip_geneve or not private_ip_geneve ): print("couldn't retrieve the required IP addresses") return while True: os.system("clear") display_stuff_privateiranfive5( local_ip_private, remote_ip_private, private_ip_private ) display_stuff_gre6(local_ip_gre6, remote_ip_gre6, private_ip_gre6) display_stuff_geneve_greiran(remote_ip_geneve, private_ip_geneve) display_ipsecsecretgengre(ipsecsecret) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve GRE6 + IPSEC\033[93m IRAN [5] Menu\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[93mChange \033[97mIRAN [5] \033[92m IPV4\033[0m") print("2. \033[93mChange \033[97mKharej\033[92m IPV4\033[0m") print("3.\033[93m Change \033[97mSIT \033[93mPrivate IPV6 \033[0m") print("4. \033[93mChange \033[97mGRE6 \033[93mPrivate IPV6\033[0m") print("5. \033[93mChange \033[97mGeneve \033[93mPrivate IPV6\033[0m") print("6. \033[93mChange IPsec \033[92mSecret Key\033[0m") print("7. \033[96mSave Stuff\033[0m") print("0. \033[97mback to edit local multi menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Enter your choice Plz: ") if choice == "3": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[SIT]\033[93m :\033[0m " ) if new_ip: private_ip_private = new_ip ip_parts = new_ip.split(":") if new_ip.endswith(":2"): ip_parts[-1] = "1" else: ip_parts[-1] = "2" counterpart_ip = ":".join(ip_parts) local_ip_gre6 = new_ip remote_ip_gre6 = counterpart_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "4": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[GRE6]\033[93m :\033[0m " ) if new_ip: private_ip_gre6 = new_ip remote_ip_geneve = wtb_opposite_ipgregen(new_ip) else: print("\033[91mWrong IP address\033[0m") elif choice == "5": new_ip = input( "\033[93mEnter New Private IPv6 address \033[96m[Geneve]\033[93m :\033[0m " ) if new_ip: private_ip_geneve = new_ip save_stuff_gregen5_kharej( private_ip_geneve, None, remote_ip_geneve, ipsec_secret, is_geneve=True, ) else: print("\033[91mWrong IP address\033[0m") elif choice == "1": new_ip = input("\033[93mEnter \033[92mIRAN [5]\033[93m Public IP :\033[0m ") if new_ip: local_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "2": new_ip = input("\033[93mEnter \033[92mKharej\033[93m Public IP :\033[0m ") if new_ip: remote_ip_private = new_ip else: print("\033[91mWrong IP address\033[0m") elif choice == "6": new_key = input( "\033[93mEnter new \033[92mIPsec \033[93mSecret Key: \033[0m" ) if new_key: update_ipsecsecret("/etc/ipsec.secrets", new_key) ipsecsecret = new_key else: print("\033[91mCrazy Secret Key\033[0m") elif choice == "7": save_stuff_gregen5_kharej( private_ip_private, local_ip_private, remote_ip_private, is_gre6=False ) save_stuff_gregen5_kharej( private_ip_gre6, local_ip_gre6, remote_ip_gre6, is_gre6=True ) save_stuff_gregen5_kharej( private_ip_geneve, None, remote_ip_geneve, is_gre6=False, is_geneve=True ) update_ipsec_ip(private_ip_geneve) break elif choice == "0": clear() multi_edit_local() break else: print("Invalid choice. Please select a valid option.") ### def update_sysctl(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mEnable IPV4/6 Forward Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mApply Stuff\033[0m") print("2. \033[93mRestore Stuff\033[0m") print("0.\033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": backup_sysctl() apply() break elif server_type == "2": restore_backup() break elif server_type == "0": os.system("clear") main_menu() break else: print("Invalid choice.") def locals_reset(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mReset Local tunnels Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mRegular [instant] Reset local timer\033[0m") print("2. \033[93mDelayed [30 seconds] Reset local timer\033[0m") print("0.\033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_mainmenunew() break elif server_type == "2": reset_local_mainmenunew() break elif server_type == "0": os.system("clear") main_menu() break else: print("Invalid choice.") def reset_local_mainmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mSingle\033[0m") print("2. \033[93mMulti\033[0m") print("0.\033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_menu2() break elif server_type == "2": reset_local_menu() break elif server_type == "0": os.system("clear") main_menu() break else: print("Invalid choice.") def reset_local_menu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Single Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[92mGRE6TAP\033[0m") print("6. \033[92mGRE6TAP + IPSEC\033[0m") print("7. \033[92mPrivate\033[0m") print("8. \033[93mPrivate + IPSEC\033[0m") print("9. \033[91mUninstall\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": display_menu_ipip() break elif server_type == "2": display_menu_ipip() break elif server_type == "3": display_menu_gre6() break elif server_type == "4": display_menu_gre6() break elif server_type == "5": display_menu_gre6tap() break elif server_type == "6": display_menu_gre6tap() break elif server_type == "7": display_menu_private() break elif server_type == "8": display_menu_private() break elif server_type == "9": reset_local_uninstallsingle() break elif server_type == "0": os.system("clear") reset_local_mainmenu() break else: print("Invalid choice.") def display_menu_ipip(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": enable_reset_ip6ip6kharejmenu() elif choice == "2": enable_reset_ip6ip6iranmenu() else: print("Please select 1 or 2") def enable_reset_ip6ip6kharejmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip6kharej(interval_seconds) reset_ping_ipip6kharej1() resetping_service_ipip1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip6iranmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip6iran(interval_seconds) reset_ping_ipip6iran1() resetping_service_ipip1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def reset_ping_ipip6kharej1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_ipip6iran1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_ipip1(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) def reset_local_ip6ip6kharej(interval): service_name = "ip6ip6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip1.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumip down ip link delete azumip /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/ipip.sh ping -c 1 2002:0db8:1234:a220::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local_ip6ip6iran(interval): service_name = "ip6ip6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip1.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumip down ip link delete azumip /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/ipip.sh ping -c 1 2002:0db8:1234:a220::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def display_menu_private(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": enable_reset_privatekharejmenu() elif choice == "2": enable_reset_privateiranmenu() else: print("Please select 1 or 2") def enable_reset_privatekharejmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_privatekharej(interval_seconds) reset_ping_privatekharej1() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_privateiranmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_privateiran(interval_seconds) reset_ping_privateiran1() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def reset_ping_privatekharej1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_privateiran1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_private1(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 6to4-1 def reset_local_privatekharej(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi /bin/bash /etc/private.sh ping -c 1 2002:831b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local_privateiran(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi /bin/bash /etc/private.sh ping -c 1 2002:831b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def display_menu_gre6(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": enable_reset_gre6kharejmenu() elif choice == "2": enable_reset_gre6iranmenu() else: print("Please select 1 or 2") def enable_reset_gre6kharejmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6kharej(interval_seconds) reset_ping_gre6kharej1() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6iranmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6iran(interval_seconds) reset_ping_gre6iran1() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def reset_ping_gre6kharej1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre6iran1(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_gre61(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # gre61 def reset_local_gre6kharej(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local_gre6iran(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def display_menu_gre6tap(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": enable_reset_gre6tapkharejmenu() elif choice == "2": enable_reset_gre6tapiranmenu() else: print("Please select 1 or 2") def enable_reset_gre6tapkharejmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tapkharej(interval_seconds) reset_ping_gre6kharej1() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") enable_ipv45forward_called = False def enable_reset_gre6tapiranmenu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tapiran(interval_seconds) reset_ping_gre6iran1() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # gre6tap1 def reset_local_gre6tapkharej(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local_gre6tapiran(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Multi Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[92mGRE6TAP\033[0m") print("6. \033[92mGRE6TAP + IPSEC\033[0m") print("7. \033[92m6TO4\033[0m") print("8. \033[93m6TO4 + IPSEC\033[0m") print("9. \033[91mUninstall\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6menu() break elif server_type == "2": reset_local_ip6ip6sec() break elif server_type == "3": reset_local_gre6menu() break elif server_type == "4": reset_local_gre6sec() break elif server_type == "5": reset_local_gre6tapmenu() break elif server_type == "6": reset_local_gre6tapsec() break elif server_type == "7": reset_local_privatemenu() break elif server_type == "8": reset_local_privatesec() break elif server_type == "9": reset_local_uninstall() break elif server_type == "0": os.system("clear") reset_local_mainmenu() break else: print("Invalid choice.") def reset_local_uninstall(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset local Uninstall Multi Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[94mGRE6TAP\033[0m") print("6. \033[93mGRE6TAP + IPSEC\033[0m") print("7. \033[92m6TO4\033[0m") print("8. \033[93m6TO4 + IPSEC\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnu() break elif server_type == "2": ipip6_reset_rmvmnu() break elif server_type == "3": gre6_reset_rmvmnu() break elif server_type == "4": gre6_reset_rmvmnu() break elif server_type == "5": gre6_reset_rmvmnu() break elif server_type == "6": gre6_reset_rmvmnu() break elif server_type == "7": private_reset_rmvmnu() break elif server_type == "8": private_reset_rmvmnu() break elif server_type == "0": os.system("clear") reset_local_mainmenu() break else: print("Invalid choice.") def reset_local_uninstallsingle(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Uninstall Single Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[94mGRE6TAP\033[0m") print("6. \033[93mGRE6TAP + IPSEC\033[0m") print("7. \033[92mPrivate\033[0m") print("8. \033[93mPrivate + IPSEC\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnussingle() break elif server_type == "2": ipip6_reset_rmvmnussingle() break elif server_type == "3": gre6_reset_rmvmnusingle() break elif server_type == "4": gre6_reset_rmvmnusingle() break elif server_type == "5": gre6_reset_rmvmnusingle() break elif server_type == "6": gre6_reset_rmvmnusingle() break elif server_type == "7": private_reset_rmvmnusingle() break elif server_type == "8": private_reset_rmvmnusingle() break elif server_type == "0": os.system("clear") reset_local_mainmenu() break else: print("Invalid choice.") def gre6_reset_rmvmnu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "sudo rm /etc/reset_gre61.sh", "sudo rm /etc/reset_gre62.sh", "sudo rm /etc/reset_gre63.sh", "sudo rm /etc/reset_gre64.sh", "sudo rm /etc/reset_gre65.sh", "sudo rm /etc/reset_gre66.sh", "sudo rm /etc/reset_gre67.sh", "sudo rm /etc/reset_gre68.sh", "sudo rm /etc/reset_gre69.sh", "sudo rm /etc/resetbasedonping1.sh", "sudo rm /etc/resetbasedonping2.sh", "sudo rm /etc/resetbasedonping3.sh", "sudo rm /etc/resetbasedonping4.sh", "sudo rm /etc/resetbasedonping5.sh", "sudo rm /etc/resetbasedonping6.sh", "sudo rm /etc/resetbasedonping7.sh", "sudo rm /etc/resetbasedonping8.sh", "sudo rm /etc/resetbasedonping9.sh", "sudo rm /etc/resetbasedonping10.sh", "systemctl disable azumireset1.service", "systemctl stop azumireset1.service", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl disable azumireset2.service", "systemctl stop azumireset2.service", "sudo rm /etc/systemd/system/azumireset2.service", "systemctl disable azumireset3.service", "systemctl stop azumireset3.service", "sudo rm /etc/systemd/system/azumireset3.service", "systemctl disable azumireset4.service", "systemctl stop azumireset4.service", "sudo rm /etc/systemd/system/azumireset4.service", "systemctl disable azumireset5.service", "systemctl stop azumireset5.service", "sudo rm /etc/systemd/system/azumireset5.service", "systemctl disable azumireset6.service", "systemctl stop azumireset6.service", "sudo rm /etc/systemd/system/azumireset6.service", "systemctl disable azumireset7.service", "systemctl stop azumireset7.service", "sudo rm /etc/systemd/system/azumireset7.service", "systemctl disable azumireset8.service", "systemctl stop azumireset8.service", "sudo rm /etc/systemd/system/azumireset8.service", "systemctl disable azumireset9.service", "systemctl stop azumireset9.service", "sudo rm /etc/systemd/system/azumireset9.service", "systemctl disable azumireset10.service", "systemctl stop azumireset10.service", "sudo rm /etc/systemd/system/azumireset10.service", "sudo rm /usr/local/bin/gre61_daemon.sh", "sudo rm /usr/local/bin/gre62_daemon.sh", "sudo rm /usr/local/bin/gre63_daemon.sh", "sudo rm /usr/local/bin/gre64_daemon.sh", "sudo rm /usr/local/bin/gre65_daemon.sh", "sudo rm /usr/local/bin/gre66_daemon.sh", "sudo rm /usr/local/bin/gre67_daemon.sh", "sudo rm /usr/local/bin/gre68_daemon.sh", "sudo rm /usr/local/bin/gre69_daemon.sh", "sudo rm /usr/local/bin/gre610_daemon.sh", "systemctl disable gre6reset1.service", "systemctl stop gre6reset1.service", "sudo rm /etc/systemd/system/gre6reset1.service", "systemctl stop gre6reset2.service", "sudo rm /etc/systemd/system/gre6reset2.service", "systemctl disable gre6reset3.service", "systemctl stop gre6reset3.service", "sudo rm /etc/systemd/system/gre6reset3.service", "systemctl disable gre6reset4.service", "systemctl stop gre6reset4.service", "sudo rm /etc/systemd/system/gre6reset4.service", "systemctl disable gre6reset5.service", "systemctl stop gre6reset5.service", "sudo rm /etc/systemd/system/gre6reset5.service", "systemctl disable gre6reset6.service", "systemctl stop gre6reset6.service", "sudo rm /etc/systemd/system/gre6reset6.service", "systemctl disable gre6reset7.service", "systemctl stop gre6reset7.service", "sudo rm /etc/systemd/system/gre6reset7.service", "systemctl disable gre6reset8.service", "systemctl stop gre6reset8.service", "sudo rm /etc/systemd/system/gre6reset8.service", "systemctl disable gre6reset9.service", "systemctl stop gre6reset9.service", "sudo rm /etc/systemd/system/gre6reset9.service", "systemctl disable gre6reset10.service", "systemctl stop gre6reset10.service", "sudo rm /etc/systemd/system/gre6reset10.service", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def private_reset_rmvmnu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "sudo rm /etc/reset_private1.sh", "sudo rm /etc/reset_private2.sh", "sudo rm /etc/reset_private3.sh", "sudo rm /etc/reset_private4.sh", "sudo rm /etc/reset_private5.sh", "sudo rm /etc/reset_private6.sh", "sudo rm /etc/reset_private7.sh", "sudo rm /etc/reset_private8.sh", "sudo rm /etc/reset_private9.sh", "sudo rm /etc/reset_private10.sh", "sudo rm /etc/resetbasedonping1.sh", "sudo rm /etc/resetbasedonping2.sh", "sudo rm /etc/resetbasedonping3.sh", "sudo rm /etc/resetbasedonping4.sh", "sudo rm /etc/resetbasedonping5.sh", "sudo rm /etc/resetbasedonping6.sh", "sudo rm /etc/resetbasedonping7.sh", "sudo rm /etc/resetbasedonping8.sh", "sudo rm /etc/resetbasedonping9.sh", "sudo rm /etc/resetbasedonping10.sh", "systemctl disable azumireset1.service", "systemctl stop azumireset1.service", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl disable azumireset2.service", "systemctl stop azumireset2.service", "sudo rm /etc/systemd/system/azumireset2.service", "systemctl disable azumireset3.service", "systemctl stop azumireset3.service", "sudo rm /etc/systemd/system/azumireset3.service", "systemctl disable azumireset4.service", "systemctl stop azumireset4.service", "sudo rm /etc/systemd/system/azumireset4.service", "systemctl disable azumireset5.service", "systemctl stop azumireset5.service", "sudo rm /etc/systemd/system/azumireset5.service", "systemctl disable azumireset6.service", "systemctl stop azumireset6.service", "sudo rm /etc/systemd/system/azumireset6.service", "systemctl disable azumireset7.service", "systemctl stop azumireset7.service", "sudo rm /etc/systemd/system/azumireset7.service", "systemctl disable azumireset8.service", "systemctl stop azumireset8.service", "sudo rm /etc/systemd/system/azumireset8.service", "systemctl disable azumireset9.service", "systemctl stop azumireset9.service", "sudo rm /etc/systemd/system/azumireset9.service", "systemctl disable azumireset10.service", "systemctl stop azumireset10.service", "sudo rm /etc/systemd/system/azumireset10.service", "sudo rm /usr/local/bin/private1_daemon.sh", "sudo rm /usr/local/bin/private2_daemon.sh", "sudo rm /usr/local/bin/private3_daemon.sh", "sudo rm /usr/local/bin/private4_daemon.sh", "sudo rm /usr/local/bin/private5_daemon.sh", "sudo rm /usr/local/bin/private6_daemon.sh", "sudo rm /usr/local/bin/private7_daemon.sh", "sudo rm /usr/local/bin/private8_daemon.sh", "sudo rm /usr/local/bin/private9_daemon.sh", "sudo rm /usr/local/bin/private10_daemon.sh", "systemctl disable privatereset1.service", "systemctl stop privatereset1.service", "sudo rm /etc/systemd/system/privatereset1.service", "systemctl disable privatereset2.service", "systemctl stop privatereset2.service", "sudo rm /etc/systemd/system/privatereset2.service", "systemctl disable privatereset3.service", "systemctl stop privatereset3.service", "sudo rm /etc/systemd/system/privatereset3.service", "systemctl disable privatereset4.service", "systemctl stop privatereset4.service", "sudo rm /etc/systemd/system/privatereset4.service", "systemctl disable privatereset5.service", "systemctl stop privatereset5.service", "sudo rm /etc/systemd/system/privatereset5.service", "systemctl disable privatereset6.service", "systemctl stop privatereset6.service", "sudo rm /etc/systemd/system/privatereset6.service", "systemctl disable privatereset7.service", "systemctl stop privatereset7.service", "sudo rm /etc/systemd/system/privatereset7.service", "systemctl disable privatereset8.service", "systemctl stop privatereset8.service", "sudo rm /etc/systemd/system/privatereset8.service", "systemctl disable privatereset9.service", "systemctl stop privatereset9.service", "sudo rm /etc/systemd/system/privatereset9.service", "systemctl disable privatereset10.service", "systemctl stop privatereset10.service", "sudo rm /etc/systemd/system/privatereset10.service", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def ipip6_reset_rmvmnu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/reset_ipip1.sh", "sudo rm /etc/reset_ipip2.sh", "sudo rm /etc/reset_ipip3.sh", "sudo rm /etc/reset_ipip4.sh", "sudo rm /etc/reset_ipip5.sh", "sudo rm /etc/reset_ipip6.sh", "sudo rm /etc/reset_ipip7.sh", "sudo rm /etc/reset_ipip8.sh", "sudo rm /etc/reset_ipip9.sh", "sudo rm /etc/reset_ipip10.sh", "sudo rm /etc/resetbasedonping1.sh", "sudo rm /etc/resetbasedonping2.sh", "sudo rm /etc/resetbasedonping3.sh", "sudo rm /etc/resetbasedonping4.sh", "sudo rm /etc/resetbasedonping5.sh", "sudo rm /etc/resetbasedonping6.sh", "sudo rm /etc/resetbasedonping7.sh", "sudo rm /etc/resetbasedonping8.sh", "sudo rm /etc/resetbasedonping9.sh", "sudo rm /etc/resetbasedonping10.sh", "systemctl disable azumireset1.service", "systemctl stop azumireset1.service", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl disable azumireset2.service", "systemctl stop azumireset2.service", "sudo rm /etc/systemd/system/azumireset2.service", "systemctl disable azumireset3.service", "systemctl stop azumireset3.service", "sudo rm /etc/systemd/system/azumireset3.service", "systemctl disable azumireset4.service", "systemctl stop azumireset4.service", "sudo rm /etc/systemd/system/azumireset4.service", "systemctl disable azumireset5.service", "systemctl stop azumireset5.service", "sudo rm /etc/systemd/system/azumireset5.service", "systemctl disable azumireset6.service", "systemctl stop azumireset6.service", "sudo rm /etc/systemd/system/azumireset6.service", "systemctl disable azumireset7.service", "systemctl stop azumireset7.service", "sudo rm /etc/systemd/system/azumireset7.service", "systemctl disable azumireset8.service", "systemctl stop azumireset8.service", "sudo rm /etc/systemd/system/azumireset8.service", "systemctl disable azumireset9.service", "systemctl stop azumireset9.service", "sudo rm /etc/systemd/system/azumireset9.service", "systemctl disable azumireset10.service", "systemctl stop azumireset10.service", "sudo rm /etc/systemd/system/azumireset10.service", "sudo rm /usr/local/bin/ipip1_daemon.sh", "sudo rm /usr/local/bin/ipip2_daemon.sh", "sudo rm /usr/local/bin/ipip3_daemon.sh", "sudo rm /usr/local/bin/ipip4_daemon.sh", "sudo rm /usr/local/bin/ipip5_daemon.sh", "sudo rm /usr/local/bin/ipip6_daemon.sh", "sudo rm /usr/local/bin/ipip7_daemon.sh", "sudo rm /usr/local/bin/ipip8_daemon.sh", "sudo rm /usr/local/bin/ipip9_daemon.sh", "sudo rm /usr/local/bin/ipip10_daemon.sh", "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "systemctl disable ip6ip6reset1.service", "systemctl stop ip6ip6reset1.service", "sudo rm /etc/systemd/system/ip6ip6reset1.service", "systemctl disable ip6ip6reset2.service", "systemctl stop ip6ip6reset2.service", "sudo rm /etc/systemd/system/ip6ip6reset2.service", "systemctl disable ip6ip6reset3.service", "systemctl stop ip6ip6reset3.service", "sudo rm /etc/systemd/system/ip6ip6reset3.service", "systemctl disable ip6ip6reset4.service", "systemctl stop ip6ip6reset4.service", "sudo rm /etc/systemd/system/ip6ip6reset4.service", "systemctl disable ip6ip6reset5.service", "systemctl stop ip6ip6reset5.service", "sudo rm /etc/systemd/system/ip6ip6reset5.service", "systemctl disable ip6ip6reset6.service", "systemctl stop ip6ip6reset6.service", "sudo rm /etc/systemd/system/ip6ip6reset6.service", "systemctl disable ip6ip6reset7.service", "systemctl stop ip6ip6reset7.service", "sudo rm /etc/systemd/system/ip6ip6reset7.service", "systemctl disable ip6ip6reset8.service", "systemctl stop ip6ip6reset8.service", "sudo rm /etc/systemd/system/ip6ip6reset8.service", "systemctl disable ip6ip6reset9.service", "systemctl stop ip6ip6reset9.service", "sudo rm /etc/systemd/system/ip6ip6reset9.service", "systemctl disable ip6ip6reset10.service", "systemctl stop ip6ip6reset10.service", "sudo rm /etc/systemd/system/ip6ip6reset10.service", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # single reset local def gre6_reset_rmvmnusingle(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/reset_gre61.sh", "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "sudo rm /usr/local/bin/gre61_daemon.sh", "systemctl disable gre6reset1.service", "systemctl stop gre6reset1.service", "sudo rm /etc/systemd/system/gre6reset1.service", "sudo rm /etc/resetbasedonping1.sh", "systemctl disable azumireset1.service", "systemctl stop azumireset1.service", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def private_reset_rmvmnusingle(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/reset_private1.sh", "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "sudo rm /usr/local/bin/private1_daemon.sh", "systemctl disable privatereset1.service", "systemctl stop privatereset1.service", "sudo rm /etc/systemd/system/privatereset1.service", "sudo rm /etc/resetbasedonping1.sh", "systemctl disable azumireset1.service", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def ipip6_reset_rmvmnussingle(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Reset timer for local\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "sudo rm /etc/reset_ipip1.sh", "sudo rm /usr/local/bin/ipip1_daemon.sh", "sudo rm /etc/ipv4.sh", "systemctl disable ipv4", "systemctl stop ipv4", "sudo rm /etc/systemd/system/ipv4.service" "systemctl disable ip6ip6reset1", "systemctl stop ip6ip6reset1", "sudo rm /etc/systemd/system/ip6ip6reset1.service", "sudo rm /etc/resetbasedonping1.sh", "systemctl disable azumireset1", "systemctl stop azumireset1", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def reset_local_ip6ip6menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m IP6IP6 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [10] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6kharejmulti() break elif server_type == "2": reset_local_ip6ip6iranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_ip6ip6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m IP6IP6 + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6kharejsecmulti() break elif server_type == "2": reset_local_ip6ip6iransecmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_ip6ip6kharejmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_ip6ip61() break elif server_type == "2": enable_reset_ip6ip62() break elif server_type == "3": enable_reset_ip6ip63() break elif server_type == "4": enable_reset_ip6ip64() break elif server_type == "5": enable_reset_ip6ip65() break elif server_type == "6": enable_reset_ip6ip66() break elif server_type == "7": enable_reset_ip6ip67() break elif server_type == "8": enable_reset_ip6ip68() break elif server_type == "9": enable_reset_ip6ip69() break elif server_type == "10": enable_reset_ip6ip610() break elif server_type == "11": kharej_resetlocal_q() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menu() break else: print("Invalid choice.") def reset_local_ip6ip6kharejsecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_ip6ip61() break elif server_type == "2": enable_reset_ip6ip62() break elif server_type == "3": enable_reset_ip6ip63() break elif server_type == "4": enable_reset_ip6ip64() break elif server_type == "5": enable_reset_ip6ip65() break elif server_type == "6": kharej_resetlocal_q() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menu() break else: print("Invalid choice.") def kharej_resetlocal_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_ip6ip6{}ir".format(i) globals()[menu_name]() def reset_local_ip6ip6iranmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_ip6ip61ir() break elif server_type == "2": enable_reset_ip6ip62ir() break elif server_type == "3": enable_reset_ip6ip63ir() break elif server_type == "4": enable_reset_ip6ip64ir() break elif server_type == "5": enable_reset_ip6ip65ir() break elif server_type == "6": enable_reset_ip6ip66ir() break elif server_type == "7": enable_reset_ip6ip67ir() break elif server_type == "8": enable_reset_ip6ip68ir() break elif server_type == "9": enable_reset_ip6ip69ir() break elif server_type == "10": enable_reset_ip6ip610ir() break elif server_type == "11": iran_resetlocal_q() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menu() break else: print("Invalid choice.") def reset_local_ip6ip6iransecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_ip6ip61ir() break elif server_type == "2": enable_reset_ip6ip62ir() break elif server_type == "3": enable_reset_ip6ip63ir() break elif server_type == "4": enable_reset_ip6ip64ir() break elif server_type == "5": enable_reset_ip6ip65ir() break elif server_type == "6": iran_resetlocal_q() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menu() break else: print("Invalid choice.") def iran_resetlocal_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_ip6ip6{}".format(i) globals()[menu_name]() # gre6 def reset_local_gre6menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6kharejmulti() break elif server_type == "2": reset_local_gre6iranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_gre6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6 + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6kharejsecmulti() break elif server_type == "2": reset_local_gre6iranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_gre6kharejmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre61() break elif server_type == "2": enable_reset_gre62() break elif server_type == "3": enable_reset_gre63() break elif server_type == "4": enable_reset_gre64() break elif server_type == "5": enable_reset_gre65() break elif server_type == "6": enable_reset_gre66() break elif server_type == "7": enable_reset_gre67() break elif server_type == "8": enable_reset_gre68() break elif server_type == "9": enable_reset_gre69() break elif server_type == "10": enable_reset_gre610() break elif server_type == "11": kharej_resetlocalgre_q() break elif server_type == "0": os.system("clear") reset_local_gre6menu() break else: print("Invalid choice.") def reset_local_gre6kharejsecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre61() break elif server_type == "2": enable_reset_gre62() break elif server_type == "3": enable_reset_gre63() break elif server_type == "4": enable_reset_gre64() break elif server_type == "5": enable_reset_gre65() break elif server_type == "6": kharej_resetlocalgre_q() break elif server_type == "0": os.system("clear") reset_local_gre6menu() break else: print("Invalid choice.") def kharej_resetlocalgre_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_gre6{}ir".format(i) globals()[menu_name]() def reset_local_gre6iranmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre61ir() break elif server_type == "2": enable_reset_gre62ir() break elif server_type == "3": enable_reset_gre63ir() break elif server_type == "4": enable_reset_gre64ir() break elif server_type == "5": enable_reset_gre65ir() break elif server_type == "6": iran_resetlocalgre6_q() break elif server_type == "0": os.system("clear") reset_local_gre6menu() break else: print("Invalid choice.") def iran_resetlocalgre6_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_gre6{}".format(i) globals()[menu_name]() # gretap def reset_local_gre6tapmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6TAP Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6tapkharejmulti() break elif server_type == "2": reset_local_gre6tapiranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_gre6tapsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6TAP + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6tapkharejsecmulti() break elif server_type == "2": reset_local_gre6tapiranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_gre6tapkharejmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre6tap1() # return break elif server_type == "2": enable_reset_gre6tap2() break elif server_type == "3": enable_reset_gre6tap3() break elif server_type == "4": enable_reset_gre6tap4() break elif server_type == "5": enable_reset_gre6tap5() break elif server_type == "6": enable_reset_gre6tap6() break elif server_type == "7": enable_reset_gre6tap7() break elif server_type == "8": enable_reset_gre6tap8() break elif server_type == "9": enable_reset_gre6tap9() break elif server_type == "10": enable_reset_gre6tap10() break elif server_type == "11": kharej_resetlocalgretap_q() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenu() break else: print("Invalid choice.") def reset_local_gre6tapkharejsecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre6tap1() break elif server_type == "2": enable_reset_gre6tap2() break elif server_type == "3": enable_reset_gre6tap3() break elif server_type == "4": enable_reset_gre6tap4() break elif server_type == "5": enable_reset_gre6tap5() break elif server_type == "6": kharej_resetlocalgretap_q() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenu() break else: print("Invalid choice.") def kharej_resetlocalgretap_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_gre6tap{}ir".format(i) globals()[menu_name]() def reset_local_gre6tapiranmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_gre6tap1ir() break elif server_type == "2": enable_reset_gre6tap2ir() break elif server_type == "3": enable_reset_gre6tap3ir() break elif server_type == "4": enable_reset_gre6tap4ir() break elif server_type == "5": enable_reset_gre6tap5ir() break elif server_type == "6": iran_resetlocalgre6tap_q() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenu() break else: print("Invalid choice.") def iran_resetlocalgre6tap_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_gre6tap{}".format(i) globals()[menu_name]() # private def reset_local_privatemenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m 6TO4 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_privatekharejmulti() break elif server_type == "2": reset_local_privateiranmulti() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_privatesec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Private + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_privatekharejsecmulti() break elif server_type == "2": reset_local_privateiransec() break elif server_type == "0": os.system("clear") reset_local_menu() break else: print("Invalid choice.") def reset_local_privatekharejmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1() break elif server_type == "2": enable_reset_private2() break elif server_type == "3": enable_reset_private3() break elif server_type == "4": enable_reset_private4() break elif server_type == "5": enable_reset_private5() break elif server_type == "6": enable_reset_private6() break elif server_type == "7": enable_reset_private7() break elif server_type == "8": enable_reset_private8() break elif server_type == "9": enable_reset_private9() break elif server_type == "10": enable_reset_private10() break elif server_type == "11": kharej_resetlocalprivate_q() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def reset_local_privatekharejsecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1sec() break elif server_type == "2": enable_reset_private2sec() break elif server_type == "3": enable_reset_private3sec() break elif server_type == "4": enable_reset_private4sec() break elif server_type == "5": enable_reset_private5sec() break elif server_type == "6": kharej_resetlocalprivate_qsec() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def kharej_resetlocalprivate_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}ir".format(i) globals()[menu_name]() def kharej_resetlocalprivate_qsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}irsec".format(i) globals()[menu_name]() def reset_local_privateiranmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1ir() break elif server_type == "2": enable_reset_private2ir() break elif server_type == "3": enable_reset_private3ir() break elif server_type == "4": enable_reset_private4ir() break elif server_type == "5": enable_reset_private5ir() break elif server_type == "6": iran_resetlocalprivate_q() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def reset_local_privateiransecmulti(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1irsec() break elif server_type == "2": enable_reset_private2irsec() break elif server_type == "3": enable_reset_private3irsec() break elif server_type == "4": enable_reset_private4irsec() break elif server_type == "5": enable_reset_private5irsec() break elif server_type == "6": iran_resetlocalprivate_qsec() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def iran_resetlocalprivate_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}".format(i) globals()[menu_name]() def iran_resetlocalprivate_qsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}sec".format(i) globals()[menu_name]() def reset_local_privateiransec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1ir() break elif server_type == "2": enable_reset_private2ir() break elif server_type == "3": enable_reset_private3ir() break elif server_type == "4": enable_reset_private4ir() break elif server_type == "5": enable_reset_private5ir() break elif server_type == "6": iran_resetlocalprivate_q() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def iran_resetlocalprivate_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}".format(i) globals()[menu_name]() def enable_reset_ip6ip61(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip61(interval_seconds) reset_ping_ipip61kharej() resetping_service_ipip61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip62(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip62(interval_seconds) reset_ping_ipip62kharej() resetping_service_ipip62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip63(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip63(interval_seconds) reset_ping_ipip63kharej() resetping_service_ipip63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip64(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip64(interval_seconds) reset_ping_ipip64kharej() resetping_service_ipip64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip65(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip65(interval_seconds) reset_ping_ipip65kharej() resetping_service_ipip65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip66(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip66(interval_seconds) reset_ping_ipip66kharej() resetping_service_ipip66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip67(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip67(interval_seconds) reset_ping_ipip67kharej() resetping_service_ipip67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip68(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip68(interval_seconds) reset_ping_ipip68kharej() resetping_service_ipip68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip69(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip69(interval_seconds) reset_ping_ipip69kharej() resetping_service_ipip69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip610(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip610(interval_seconds) reset_ping_ipip610kharej() resetping_service_ipip610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # ip6ip61 def reset_local_ip6ip61(interval): service_name = "ip6ip6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip1.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumip1 down ip link delete azumip1 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 /bin/bash /etc/ipip1.sh ping -c 1 2002:0db8:1234:a020::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ipip62 def reset_local_ip6ip62(interval): service_name = "ip6ip6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip2.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumip2 down ip link delete azumip2 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 /bin/bash /etc/ipip2.sh ping -c 1 2002:0db8:1234:a120::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ipip63 def reset_local_ip6ip63(interval): service_name = "ip6ip6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip3.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumip3 down ip link delete azumip3 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 /bin/bash /etc/ipip3.sh ping -c 1 2002:0db8:1234:a220::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip64 def reset_local_ip6ip64(interval): service_name = "ip6ip6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip4.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumip4 down ip link delete azumip4 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 /bin/bash /etc/ipip4.sh ping -c 1 2002:0db8:1234:a320::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip65 def reset_local_ip6ip65(interval): service_name = "ip6ip6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip5.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumip5 down ip link delete azumip5 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 /bin/bash /etc/ipip5.sh ping -c 1 2002:0db8:1234:a420::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip66 def reset_local_ip6ip66(interval): service_name = "ip6ip6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip6.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip6_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip6_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip6_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumip6 down ip link delete azumip6 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 /bin/bash /etc/ipip6.sh ping -c 1 2002:0db8:1234:a520::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip6.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip6.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip67 def reset_local_ip6ip67(interval): service_name = "ip6ip6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip7.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip7_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip7_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip7_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumip7 down ip link delete azumip7 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 /bin/bash /etc/ipip7.sh ping -c 1 2002:0db8:1234:a620::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip7.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip7.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip68 def reset_local_ip6ip68(interval): service_name = "ip6ip6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip8.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip8_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip8_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip8_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumip8 down ip link delete azumip8 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 /bin/bash /etc/ipip8.sh ping -c 1 2002:0db8:1234:a720::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip8.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip8.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip69 def reset_local_ip6ip69(interval): service_name = "ip6ip6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip9.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip9_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip9_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip9_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumip9 down ip link delete azumip9 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 /bin/bash /etc/ipip9.sh ping -c 1 2002:0db8:1234:a820::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip9.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip9.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip610 def reset_local_ip6ip610(interval): service_name = "ip6ip6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip10.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip10_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip10_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip10_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumip10 down ip link delete azumip10 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 /bin/bash /etc/ipip10.sh ping -c 1 2002:0db8:1234:a920::2 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip10.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip10.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def enable_reset_ip6ip61ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip61ir(interval_seconds) reset_ping_ipip61iran() resetping_service_ipip61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip62ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip62ir(interval_seconds) reset_ping_ipip62iran() resetping_service_ipip62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip63ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip63ir(interval_seconds) reset_ping_ipip63iran() resetping_service_ipip63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip64ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip64ir(interval_seconds) reset_ping_ipip64iran() resetping_service_ipip64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip65ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip65ir(interval_seconds) reset_ping_ipip65iran() resetping_service_ipip65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip66ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip66ir(interval_seconds) reset_ping_ipip66iran() resetping_service_ipip66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip67ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip67ir(interval_seconds) reset_ping_ipip67iran() resetping_service_ipip67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip68ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip68ir(interval_seconds) reset_ping_ipip68iran() resetping_service_ipip68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip69ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip69ir(interval_seconds) reset_ping_ipip69iran() resetping_service_ipip69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_ip6ip610ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_ip6ip610ir(interval_seconds) reset_ping_ipip610iran() resetping_service_ipip610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # ip6ip61 def reset_local_ip6ip61ir(interval): service_name = "ip6ip6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip1.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumip1 down ip link delete azumip1 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 /bin/bash /etc/ipip1.sh ping -c 1 2002:0db8:1234:a020::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ipip62 def reset_local_ip6ip62ir(interval): service_name = "ip6ip6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip2.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumip2 down ip link delete azumip2 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 /bin/bash /etc/ipip2.sh ping -c 1 2002:0db8:1234:a120::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ipip63 def reset_local_ip6ip63ir(interval): service_name = "ip6ip6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip3.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumip3 down ip link delete azumip3 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 /bin/bash /etc/ipip3.sh ping -c 1 2002:0db8:1234:a220::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip64 def reset_local_ip6ip64ir(interval): service_name = "ip6ip6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip4.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumip4 down ip link delete azumip4 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 /bin/bash /etc/ipip4.sh ping -c 1 2002:0db8:1234:a320::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip65 def reset_local_ip6ip65ir(interval): service_name = "ip6ip6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip5.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumip5 down ip link delete azumip5 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 /bin/bash /etc/ipip5.sh ping -c 1 2002:0db8:1234:a420::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip66 def reset_local_ip6ip66ir(interval): service_name = "ip6ip6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip6.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip6_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip6_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip6_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumip6 down ip link delete azumip6 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 /bin/bash /etc/ipip6.sh ping -c 1 2002:0db8:1234:a520::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip6.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip6.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip67 def reset_local_ip6ip67ir(interval): service_name = "ip6ip6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip7.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip7_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip7_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip7_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 ip link delete azumi7 ip link set dev azumip7 ip link delete azumip7 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 /bin/bash /etc/ipip7.sh ping -c 1 2002:0db8:1234:a620::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip7.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip7.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip68 def reset_local_ip6ip68ir(interval): service_name = "ip6ip6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip8.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip8_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip8_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip8_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumip8 down ip link delete azumip8 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 /bin/bash /etc/ipip8.sh ping -c 1 2002:0db8:1234:a720::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip8.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip8.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip69 def reset_local_ip6ip69ir(interval): service_name = "ip6ip6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip9.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip9_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip9_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip9_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumip9 down ip link delete azumip9 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 /bin/bash /etc/ipip9.sh ping -c 1 2002:0db8:1234:a820::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip9.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip9.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ip6ip610 def reset_local_ip6ip610ir(interval): service_name = "ip6ip6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipip10.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipip10_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipip10_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipip10_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumip10 down ip link delete azumip10 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 /bin/bash /etc/ipip10.sh ping -c 1 2002:0db8:1234:a920::1 systemctl restart strong-azumi1 """ with open("/etc/reset_ipip10.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipip10.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # reset def reset_ping_ipip61kharej(): script_content = f"""#!/bin/bash while true; do ping -c 4 2002:0db8:1234:a020::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip1.sh fi sleep done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_ipip61iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a020::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_ipip61(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_ipip62kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a120::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_ipip62iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a120::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_ipip62(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 3 def reset_ping_ipip63kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_ipip63iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_ipip63(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_ipip64kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a320::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_ipip64iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a320::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_ipip64(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_ipip65kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a420::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_ipip65iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a420::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_ipip65(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_ipip66kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a520::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip6.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_ipip66iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a520::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip6.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_ipip66(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_ipip67kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a620::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip7.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_ipip67iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a620::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip7.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_ipip67(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_ipip68kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a720::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip8.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_ipip68iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a720::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip8.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_ipip68(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_ipip69kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a820::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip9.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_ipip69iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a820::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip9.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_ipip69(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_ipip610kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a920::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip10.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_ipip610iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a920::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_ipip10.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_ipip610(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) def enable_reset_gre61(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre61(interval_seconds) reset_ping_gre61kharej() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre62(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre62(interval_seconds) reset_ping_gre62kharej() resetping_service_gre62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre63(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre63(interval_seconds) reset_ping_gre63kharej() resetping_service_gre63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre64(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre64(interval_seconds) reset_ping_gre64kharej() resetping_service_gre64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre65(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre65(interval_seconds) reset_ping_gre65kharej() resetping_service_gre65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre66(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre66(interval_seconds) reset_ping_gre66kharej() resetping_service_gre66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre67(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre67(interval_seconds) reset_ping_gre67kharej() resetping_service_gre67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre68(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre68(interval_seconds) reset_ping_gre68kharej() resetping_service_gre68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre69(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre69(interval_seconds) reset_ping_gre69kharej() resetping_service_gre69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre610(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre610(interval_seconds) reset_ping_gre610kharej() resetping_service_gre610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # gre61 def reset_local_gre61(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre62 def reset_local_gre62(interval): service_name = "gre6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre62.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre62_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre62_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre62_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre62.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre62.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre63 def reset_local_gre63(interval): service_name = "gre6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre63.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre63_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre63_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre63_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre63.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre63.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre64(interval): service_name = "gre6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre64.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre64_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre64_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre64_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre64.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre64.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre65(interval): service_name = "gre6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre65.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre65_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre65_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre65_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre65.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre65.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre66 def reset_local_gre66(interval): service_name = "gre6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre66.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre66_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre66_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre66_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre66.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre66.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre67 def reset_local_gre67(interval): service_name = "gre6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre67.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre67_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre67_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre67_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre67.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre67.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre68 def reset_local_gre68(interval): service_name = "gre6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre68.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre68_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre68_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre68_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre68.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre68.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre69 def reset_local_gre69(interval): service_name = "gre6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre69.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre69_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre69_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre69_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre69.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre69.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre610 def reset_local_gre610(interval): service_name = "gre6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre610.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre610_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre610_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre610_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre610.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre610.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def enable_reset_gre61ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre61ir(interval_seconds) reset_ping_gre61iran() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre62ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre62ir(interval_seconds) reset_ping_gre62iran() resetping_service_gre62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre63ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre63ir(interval_seconds) reset_ping_gre63iran() resetping_service_gre63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre64ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre64ir(interval_seconds) reset_ping_gre64iran() resetping_service_gre64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre65ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre65ir(interval_seconds) reset_ping_gre65iran() resetping_service_gre65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre66ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre66ir(interval_seconds) reset_ping_gre66iran() resetping_service_gre66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre67ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre67ir(interval_seconds) reset_ping_gre67iran() resetping_service_gre67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre68ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre68ir(interval_seconds) reset_ping_gre68iran() resetping_service_gre68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre69ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre69ir(interval_seconds) reset_ping_gre69iran() resetping_service_gre69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre610ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre610ir(interval_seconds) reset_ping_gre610iran() resetping_service_gre610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # gre61 def reset_local_gre61ir(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre662 def reset_local_gre62ir(interval): service_name = "gre6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre62.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre62_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre62_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre62_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre62.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre62.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre663 def reset_local_gre63ir(interval): service_name = "gre6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre63.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre63_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre63_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre63_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre63.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre63.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre64ir(interval): service_name = "gre6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre64.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre64_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre64_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre64_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre64.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre64.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre65 def reset_local_gre65ir(interval): service_name = "gre6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre65.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre65_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre65_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre65_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre65.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre65.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre66 def reset_local_gre66ir(interval): service_name = "gre6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre66.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre66_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre66_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre66_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre66.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre66.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre67 def reset_local_gre67ir(interval): service_name = "gre6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre67.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre67_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre67_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre67_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre67.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre67.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre68 def reset_local_gre68ir(interval): service_name = "gre6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre68.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre68_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre68_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre68_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre68.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre68.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre69 def reset_local_gre69ir(interval): service_name = "gre6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre69.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre69_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre69_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre69_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre69.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre69.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre610 def reset_local_gre610ir(interval): service_name = "gre6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre610.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre610_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre610_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre610_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set down azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre610.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre610.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # reset def reset_ping_gre61kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre61iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_gre61(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_gre62kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre62.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_gre62iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre62.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_gre62(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 2 def reset_ping_gre63kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre63.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_gre63iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre63.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_gre63(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_gre64kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre64.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_gre64iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre64.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_gre64(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_gre65kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre65.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_gre65iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre65.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_gre65(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_gre66kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre66.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_gre66iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre66.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_gre66(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_gre67kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre67.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_gre67iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre67.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_gre67(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_gre68kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre68.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_gre68iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre68.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_gre68(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_gre69kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre69.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_gre69iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre69.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_gre69(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_gre610kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre610.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_gre610iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre610.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_gre610(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) def enable_ipv45forward(): print("\033[93m────────────────────────────────────────\033[0m") ip4_enable = input( "\033[93mDo you want \033[92mIPV4/6 \033[93mto be checked & enabled every minute? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ip4_enable in ["yes", "y"]: ipv4forwardipv6() ipv4_service() def ipv4forwardipv6(): script_content = """#!/bin/bash set_sysctl_value() { local key="$1" local value="$2" sysctl -w $key=$value if grep -q "^$key" /etc/sysctl.conf; then sed -i "s/^$key.*/$key = $value/" /etc/sysctl.conf else echo "$key = $value" >> /etc/sysctl.conf fi } while true; do set_sysctl_value net.ipv4.ip_forward 1 set_sysctl_value net.ipv6.conf.all.disable_ipv6 0 set_sysctl_value net.ipv6.conf.default.disable_ipv6 0 set_sysctl_value net.ipv6.conf.all.forwarding 1 sleep 60 done """ script_path = "/etc/ipv4.sh" with open(script_path, "w") as f: f.write(script_content) os.chmod(script_path, 0o755) def ipv4_service(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/ipv4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/ipv4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ipv4"]) subprocess.run(["systemctl", "restart", "ipv4"]) def enable_reset_gre6tap1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap1(interval_seconds) reset_ping_gre61kharej() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap2(interval_seconds) reset_ping_gre62kharej() resetping_service_gre62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap3(interval_seconds) reset_ping_gre63kharej() resetping_service_gre63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap4(interval_seconds) reset_ping_gre64kharej() resetping_service_gre64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap5(interval_seconds) reset_ping_gre65kharej() resetping_service_gre65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap6(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap6(interval_seconds) reset_ping_gre66kharej() resetping_service_gre66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap7(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap7(interval_seconds) reset_ping_gre67kharej() resetping_service_gre67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap8(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap8(interval_seconds) reset_ping_gre68kharej() resetping_service_gre68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap9(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap9(interval_seconds) reset_ping_gre69kharej() resetping_service_gre69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap10(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap10(interval_seconds) reset_ping_gre610kharej() resetping_service_gre610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # gre61 def reset_local_gre6tap1(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 /bin/bash /etc/private1.sh ping -c 1 fd1d:fc98:b73e:b081::2 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre62 def reset_local_gre6tap2(interval): service_name = "gre6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre62.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre62_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre62_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre62_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 /bin/bash /etc/private2.sh ping -c 1 fd1d:fc98:b73e:b181::2 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre62.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre62.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre63 def reset_local_gre6tap3(interval): service_name = "gre6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre63.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre63_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre63_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre63_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 /bin/bash /etc/private3.sh ping -c 1 fd1d:fc98:b73e:b281::2 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre63.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre63.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre6tap4(interval): service_name = "gre6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre64.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre64_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre64_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre64_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 /bin/bash /etc/private4.sh ping -c 1 fd1d:fc98:b73e:b381::2 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre64.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre64.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre6tap5(interval): service_name = "gre6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre65.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre65_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre65_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre65_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 /bin/bash /etc/private5.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre65.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre65.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre66 def reset_local_gre6tap6(interval): service_name = "gre6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre66.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre66_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre66_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre66_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 /bin/bash /etc/private6.sh ping -c 1 fd1d:fc98:b73e:b581::2 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre66.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre66.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre67 def reset_local_gre6tap7(interval): service_name = "gre6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre67.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre67_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre67_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre67_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 /bin/bash /etc/private7.sh ping -c 1 fd1d:fc98:b73e:b681::2 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre67.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre67.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre68 def reset_local_gre6tap8(interval): service_name = "gre6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre68.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre68_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre68_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre68_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 /bin/bash /etc/private8.sh ping -c 1 fd1d:fc98:b73e:b781::2 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre68.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre68.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre69 def reset_local_gre6tap9(interval): service_name = "gre6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre69.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre69_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre69_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre69_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 /bin/bash /etc/private9.sh ping -c 1 fd1d:fc98:b73e:b881::2 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre69.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre69.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre6tap10 def reset_local_gre6tap10(interval): service_name = "gre6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre610.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre610_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre610_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre610_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 /bin/bash /etc/private10.sh ping -c 1 fd1d:fc98:b73e:b981::2 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::2 systemctl restart strong-azumi1 """ with open("/etc/reset_gre610.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre610.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def enable_reset_gre6tap1ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap1ir(interval_seconds) reset_ping_gre61iran() resetping_service_gre61() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap2ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap2ir(interval_seconds) reset_ping_gre62iran() resetping_service_gre62() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap3ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap3ir(interval_seconds) reset_ping_gre63iran() resetping_service_gre63() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap4ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap4ir(interval_seconds) reset_ping_gre64iran() resetping_service_gre64() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap5ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap5ir(interval_seconds) reset_ping_gre65iran() resetping_service_gre65() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap6ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap6ir(interval_seconds) reset_ping_gre66iran() resetping_service_gre66() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap7ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap7ir(interval_seconds) reset_ping_gre67iran() resetping_service_gre67() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap8ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap8ir(interval_seconds) reset_ping_gre68iran() resetping_service_gre68() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap9ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap9ir(interval_seconds) reset_ping_gre69iran() resetping_service_gre69() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_gre6tap10ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_gre6tap10ir(interval_seconds) reset_ping_gre610iran() resetping_service_gre610() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # gre61 def reset_local_gre6tap1ir(interval): service_name = "gre6reset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre61.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre61_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre61_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre61_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 /bin/bash /etc/private1.sh ping -c 1 fd1d:fc98:b73e:b081::1 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre61.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre61.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre662 def reset_local_gre6tap2ir(interval): service_name = "gre6reset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre62.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre62_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre62_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre62_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 /bin/bash /etc/private2.sh ping -c 1 fd1d:fc98:b73e:b181::1 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre62.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre62.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre663 def reset_local_gre6tap3ir(interval): service_name = "gre6reset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre63.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre63_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre63_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre63_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 /bin/bash /etc/private3.sh ping -c 1 fd1d:fc98:b73e:b281::1 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre63.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre63.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre64 def reset_local_gre6tap4ir(interval): service_name = "gre6reset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre64.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre64_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre64_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre64_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 /bin/bash /etc/private4.sh ping -c 1 fd1d:fc98:b73e:b381::1 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre64.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre64.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre65 def reset_local_gre6tap5ir(interval): service_name = "gre6reset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre65.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre65_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre65_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre65_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 /bin/bash /etc/private5.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre65.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre65.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre66 def reset_local_gre6tap6ir(interval): service_name = "gre6reset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre66.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre66_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre66_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre66_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 /bin/bash /etc/private6.sh ping -c 1 fd1d:fc98:b73e:b581::1 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre66.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre66.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre67 def reset_local_gre6tap7ir(interval): service_name = "gre6reset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre67.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre67_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre67_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre67_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 /bin/bash /etc/private7.sh /bin/bash /etc/gre67.sh ping -c 1 fd1d:fc98:b73e:b681::1 ping -c 1 2002:861a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre67.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre67.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre68 def reset_local_gre6tap8ir(interval): service_name = "gre6reset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre68.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre68_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre68_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre68_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 /bin/bash /etc/private8.sh ping -c 1 fd1d:fc98:b73e:b781::1 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre68.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre68.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre69 def reset_local_gre6tap9ir(interval): service_name = "gre6reset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre69.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre69_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre69_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre69_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 /bin/bash /etc/private9.sh ping -c 1 fd1d:fc98:b73e:b881::1 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre69.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre69.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # gre610 def reset_local_gre6tap10ir(interval): service_name = "gre6reset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_gre610.sh sleep $INTERVAL done """ with open("/usr/local/bin/gre610_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/gre610_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/gre610_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 /bin/bash /etc/private10.sh ping -c 1 fd1d:fc98:b73e:b981::1 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::1 systemctl restart strong-azumi1 """ with open("/etc/reset_gre610.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_gre610.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # reset def reset_ping_gre61kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre61iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre61.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_gre61(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_gre62kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre62.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_gre62iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre62.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_gre62(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 2 def reset_ping_gre63kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre63.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_gre63iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre63.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_gre63(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_gre64kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre64.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_gre64iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre64.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_gre64(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_gre65kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre65.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_gre65iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre65.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_gre65(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_gre66kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre66.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_gre66iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre66.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_gre66(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_gre67kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre67.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_gre67iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre67.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_gre67(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_gre68kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre68.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_gre68iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre68.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_gre68(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_gre69kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre69.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_gre69iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre69.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_gre69(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_gre610kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre610.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_gre610iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_gre610.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_gre610(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) def enable_reset_private1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private1(interval_seconds) reset_ping_private1kharej() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private2(interval_seconds) reset_ping_private2kharej() resetping_service_private2() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private3(interval_seconds) reset_ping_private3kharej() resetping_service_private3() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private4(interval_seconds) reset_ping_private4kharej() resetping_service_private4() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private5(interval_seconds) reset_ping_private5kharej() resetping_service_private5() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private6(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private6(interval_seconds) reset_ping_private6kharej() resetping_service_private6() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private7(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private7(interval_seconds) reset_ping_private7kharej() resetping_service_private7() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private8(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private8(interval_seconds) reset_ping_private8kharej() resetping_service_private8() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private9(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private9(interval_seconds) reset_ping_private9kharej() resetping_service_private9() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private10(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private10(interval_seconds) reset_ping_private10kharej() resetping_service_private10() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # 6to4-1 def reset_local_private1(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-2 def reset_local_private2(interval): service_name = "privatereset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private2.sh sleep $INTERVAL done """ with open("/usr/local/bin/private2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-3 def reset_local_private3(interval): service_name = "privatereset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private3.sh sleep $INTERVAL done """ with open("/usr/local/bin/private3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-4 def reset_local_private4(interval): service_name = "privatereset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private4.sh sleep $INTERVAL done """ with open("/usr/local/bin/private4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-5 def reset_local_private5(interval): service_name = "privatereset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private5.sh sleep $INTERVAL done """ with open("/usr/local/bin/private5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # ipsec # 6to4-6 def reset_local_private6(interval): service_name = "privatereset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private6.sh sleep $INTERVAL done """ with open("/usr/local/bin/private6_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private6_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private6_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private6.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private6.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-7 def reset_local_private7(interval): service_name = "privatereset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private7.sh sleep $INTERVAL done """ with open("/usr/local/bin/private7_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private7_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private7_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private7.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private7.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-8 def reset_local_private8(interval): service_name = "privatereset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private8.sh sleep $INTERVAL done """ with open("/usr/local/bin/private8_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private8_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private8_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private8.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private8.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-9 def reset_local_private9(interval): service_name = "privatereset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private9.sh sleep $INTERVAL done """ with open("/usr/local/bin/private9_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private9_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private9_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private9.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private9.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-10 def reset_local_private10(interval): service_name = "privatereset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private10.sh sleep $INTERVAL done """ with open("/usr/local/bin/private10_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private10_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private10_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private10.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private10.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def enable_reset_private1ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private1ir(interval_seconds) reset_ping_private1iran() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private2ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private2ir(interval_seconds) reset_ping_private2iran() resetping_service_private2() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private3ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private3ir(interval_seconds) reset_ping_private3iran() resetping_service_private3() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private4ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private4ir(interval_seconds) reset_ping_private4iran() resetping_service_private4() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private5ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private5ir(interval_seconds) reset_ping_private5iran() resetping_service_private5() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private6ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private6ir(interval_seconds) reset_ping_private6iran() resetping_service_private6() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private7ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private7ir(interval_seconds) reset_ping_private7iran() resetping_service_private7() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private8ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private8ir(interval_seconds) reset_ping_private8iran() resetping_service_private8() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private9ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private9ir(interval_seconds) reset_ping_private9iran() resetping_service_private9() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private10ir(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private10ir(interval_seconds) reset_ping_private10iran() resetping_service_private10() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") # private1 def reset_local_private1ir(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private62 def reset_local_private2ir(interval): service_name = "privatereset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private2.sh sleep $INTERVAL done """ with open("/usr/local/bin/private2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private63 def reset_local_private3ir(interval): service_name = "privatereset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private3.sh sleep $INTERVAL done """ with open("/usr/local/bin/private3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private4 def reset_local_private4ir(interval): service_name = "privatereset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private4.sh sleep $INTERVAL done """ with open("/usr/local/bin/private4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private5 def reset_local_private5ir(interval): service_name = "privatereset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private5.sh sleep $INTERVAL done """ with open("/usr/local/bin/private5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private6 def reset_local_private6ir(interval): service_name = "privatereset6.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private6.sh sleep $INTERVAL done """ with open("/usr/local/bin/private6_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private6_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private6_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi6 down ip link delete azumi6 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private6.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private6.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private7 def reset_local_private7ir(interval): service_name = "privatereset7.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private7.sh sleep $INTERVAL done """ with open("/usr/local/bin/private7_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private7_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private7_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi7 down ip link delete azumi7 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private7.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private7.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private8 def reset_local_private8ir(interval): service_name = "privatereset8.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private8.sh sleep $INTERVAL done """ with open("/usr/local/bin/private8_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private8_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private8_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi8 down ip link delete azumi8 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private8.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private8.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private9 def reset_local_private9ir(interval): service_name = "privatereset9.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private9.sh sleep $INTERVAL done """ with open("/usr/local/bin/private9_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private9_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private9_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi9 down ip link delete azumi9 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private9.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private9.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private10 def reset_local_private10ir(interval): service_name = "privatereset10.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private10.sh sleep $INTERVAL done """ with open("/usr/local/bin/private10_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private10_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private10_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi10 down ip link delete azumi10 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private10.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private10.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # reset def reset_ping_private1kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_private1iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_private1(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_private2kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_private2iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_private2(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 2 def reset_ping_private3kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_private3iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_private3(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_private4kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_private4iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_private4(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_private5kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_private5iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_private5(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_private6kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private6.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_private6iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private6.sh fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_private6(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_private7kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private7.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_private7iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private7.sh fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_private7(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_private8kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private8.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_private8iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private8.sh fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_private8(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_private9kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private9.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_private9iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private9.sh fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_private9(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_private10kharej(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private10.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_private10iran(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private10.sh fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_private10(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) # ipsec private reset def enable_reset_private1sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private1sec(interval_seconds) reset_ping_private1kharejsec() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private2sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private2sec(interval_seconds) reset_ping_private2kharejsec() resetping_service_private2() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private3sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private3sec(interval_seconds) reset_ping_private3kharejsec() resetping_service_private3() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private4sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private4sec(interval_seconds) reset_ping_private4kharejsec() resetping_service_private4() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private5sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private5sec(interval_seconds) reset_ping_private5kharejsec() resetping_service_private5() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def reset_local_private1sec(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 /bin/bash /etc/private1.sh ping -c 1 2002:831b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-2 def reset_local_private2sec(interval): service_name = "privatereset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private2.sh sleep $INTERVAL done """ with open("/usr/local/bin/private2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 /bin/bash /etc/private2.sh ping -c 1 2002:841b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-3 def reset_local_private3sec(interval): service_name = "privatereset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private3.sh sleep $INTERVAL done """ with open("/usr/local/bin/private3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 /bin/bash /etc/private3.sh ping -c 1 2002:851b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-4 def reset_local_private4sec(interval): service_name = "privatereset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private4.sh sleep $INTERVAL done """ with open("/usr/local/bin/private4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 /bin/bash /etc/private4.sh ping -c 1 2002:861b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # 6to4-5 def reset_local_private5sec(interval): service_name = "privatereset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private5.sh sleep $INTERVAL done """ with open("/usr/local/bin/private5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 /bin/bash /etc/private5.sh ping -c 1 2002:871b::2 systemctl restart strong-azumi1 """ with open("/etc/reset_private5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def enable_reset_private1irsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private1irsec(interval_seconds) reset_ping_private1iransec() resetping_service_private1() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private2irsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private2irsec(interval_seconds) reset_ping_private2iransec() resetping_service_private2() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private3irsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private3irsec(interval_seconds) reset_ping_private3iransec() resetping_service_private3() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private4irsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private4irsec(interval_seconds) reset_ping_private4iransec() resetping_service_private4() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def enable_reset_private5irsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mlocal \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local_private5irsec(interval_seconds) reset_ping_private5iransec() resetping_service_private5() global enable_ipv45forward_called if not enable_ipv45forward_called: enable_ipv45forward() enable_ipv45forward_called = True print("\033[93m────────────────────────────────────────\033[0m") def reset_local_private1irsec(interval): service_name = "privatereset1.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private1.sh sleep $INTERVAL done """ with open("/usr/local/bin/private1_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private1_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private1_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi1 down ip link delete azumi1 /bin/bash /etc/private1.sh ping -c 1 2002:831b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private1.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private1.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private62 def reset_local_private2irsec(interval): service_name = "privatereset2.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private2.sh sleep $INTERVAL done """ with open("/usr/local/bin/private2_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private2_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private2_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi2 down ip link delete azumi2 /bin/bash /etc/private2.sh ping -c 1 2002:841b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private2.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private2.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private63 def reset_local_private3irsec(interval): service_name = "privatereset3.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private3.sh sleep $INTERVAL done """ with open("/usr/local/bin/private3_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private3_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private3_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi3 down ip link delete azumi3 /bin/bash /etc/private3.sh ping -c 1 2002:851b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private3.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private3.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private4 def reset_local_private4irsec(interval): service_name = "privatereset4.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private4.sh sleep $INTERVAL done """ with open("/usr/local/bin/private4_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private4_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private4_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi4 down ip link delete azumi4 /bin/bash /etc/private4.sh ping -c 1 2002:861b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private4.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private4.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # private5 def reset_local_private5irsec(interval): service_name = "privatereset5.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_private5.sh sleep $INTERVAL done """ with open("/usr/local/bin/private5_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/private5_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/private5_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link set dev azumi5 down ip link delete azumi5 /bin/bash /etc/private5.sh ping -c 1 2002:871b::1 systemctl restart strong-azumi1 """ with open("/etc/reset_private5.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_private5.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) # reset def reset_ping_private1kharejsec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_private1iransec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private1.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) # 2 def reset_ping_private2kharejsec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_private2iransec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private2.sh fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) # 3 def reset_ping_private3kharejsec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_private3iransec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private3.sh fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) # 4 def reset_ping_private4kharejsec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_private4iransec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private4.sh fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) # 5 def reset_ping_private5kharejsec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_private5iransec(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_private5.sh fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) # test reset # single # ipip def reset_local_mainmenunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Menu [Test]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mSingle\033[0m") print("2. \033[93mMulti\033[0m") print("0.\033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_menu2new() break elif server_type == "2": reset_local_menunew() break elif server_type == "0": os.system("clear") main_menu() break else: print("Invalid choice.") def reset_local_menu2new(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Single Menu [Test]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[92mGRE6TAP\033[0m") print("6. \033[92mGRE6TAP + IPSEC\033[0m") print("7. \033[92mPrivate\033[0m") print("8. \033[93mPrivate + IPSEC\033[0m") print("9. \033[91mUninstall\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": display_menu_ipipnew() break elif server_type == "2": display_menu_ipipnew() break elif server_type == "3": display_menu_gre6new() break elif server_type == "4": display_menu_gre6new() break elif server_type == "5": display_menu_gre6new() break elif server_type == "6": display_menu_gre6new() break elif server_type == "7": display_menu_privatenew() break elif server_type == "8": display_menu_privatenew() break elif server_type == "9": reset_local_uninstallsingle() break elif server_type == "0": os.system("clear") reset_local_mainmenunew() break else: print("Invalid choice.") def display_menu_ipipnew(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": reset_ping_ipip6kharej1new() resetping_service_ipip1new() enable_ipv45forward() elif choice == "2": reset_ping_ipip6iran1new() resetping_service_ipip1new() enable_ipv45forward() else: print("Please select 1 or 2") def display_menu_privatenew(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": reset_ping_privatekharej1new() resetping_service_private1new() enable_ipv45forward() elif choice == "2": reset_ping_privateiran1new() resetping_service_private1new() enable_ipv45forward() else: print("Please select 1 or 2") def display_menu_gre6new(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") choice = input("Select an option (1 or 2): ") if choice == "1": reset_ping_gre6kharej1new() resetping_service_gre61new() enable_ipv45forward() elif choice == "2": reset_ping_gre6iran1new() resetping_service_gre61new() enable_ipv45forward() else: print("Please select 1 or 2") def reset_local_menunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Reset Local Multi Menu[Test]\033[0m") print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6\033[0m") print("2. \033[94mIP6IP6 + IPSEC\033[0m") print("3. \033[93mGRE6\033[0m") print("4. \033[92mGRE6 + IPSEC\033[0m") print("5. \033[92mGRE6TAP\033[0m") print("6. \033[92mGRE6TAP + IPSEC\033[0m") print("7. \033[92m6TO4\033[0m") print("8. \033[93m6TO4 + IPSEC\033[0m") print("9. \033[91mUninstall\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6menunew() break elif server_type == "2": reset_local_ip6ip6secnew() break elif server_type == "3": reset_local_gre6menunew() break elif server_type == "4": reset_local_gre6secnew() break elif server_type == "5": reset_local_gre6tapmenunew() break elif server_type == "6": reset_local_gre6tapsecnew() break elif server_type == "7": reset_local_privatemenunew() break elif server_type == "8": reset_local_privatesecnew() break elif server_type == "9": reset_local_uninstall() break elif server_type == "0": os.system("clear") reset_local_mainmenunew() break else: print("Invalid choice.") def reset_local_ip6ip6menunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m IP6IP6 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [10] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6kharejmultinew() break elif server_type == "2": reset_local_ip6ip6iranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_ip6ip6secnew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m IP6IP6 + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_ip6ip6kharejsecmultinew() break elif server_type == "2": reset_local_ip6ip6iransecmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_ip6ip6kharejmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_ipip61kharejnew() resetping_service_ipip61new() enable_ipv45forward() break elif server_type == "2": reset_ping_ipip62kharejnew() resetping_service_ipip62new() enable_ipv45forward() break elif server_type == "3": reset_ping_ipip63kharejnew() resetping_service_ipip63new() enable_ipv45forward() break elif server_type == "4": reset_ping_ipip64kharejnew() resetping_service_ipip64new() enable_ipv45forward() break elif server_type == "5": reset_ping_ipip65kharejnew() resetping_service_ipip65new() enable_ipv45forward() break elif server_type == "6": reset_ping_ipip66kharejnew() resetping_service_ipip66new() enable_ipv45forward() break elif server_type == "7": reset_ping_ipip67kharejnew() resetping_service_ipip67new() enable_ipv45forward() break elif server_type == "8": reset_ping_ipip68kharejnew() resetping_service_ipip68new() enable_ipv45forward() break elif server_type == "9": reset_ping_ipip69kharejnew() resetping_service_ipip69new() enable_ipv45forward() break elif server_type == "10": reset_ping_ipip610kharejnew() resetping_service_ipip610new() enable_ipv45forward() break elif server_type == "11": kharej_resetlocal_qnew() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menunew() break else: print("Invalid choice.") def reset_local_ip6ip6kharejsecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_ipip61kharejnew() resetping_service_ipip61new() enable_ipv45forward() break elif server_type == "2": reset_ping_ipip62kharejnew() resetping_service_ipip62new() enable_ipv45forward() break elif server_type == "3": reset_ping_ipip63kharejnew() resetping_service_ipip63new() enable_ipv45forward() break elif server_type == "4": reset_ping_ipip64kharejnew() resetping_service_ipip64new() enable_ipv45forward() break elif server_type == "5": reset_ping_ipip65kharejnew() resetping_service_ipip65new() enable_ipv45forward() break elif server_type == "6": kharej_resetlocal_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menunew() break else: print("Invalid choice.") def kharej_resetlocal_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_ipip6{i}irannew" resetping_service_private_name = f"resetping_service_ipip6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def reset_local_ip6ip6iranmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_ipip61irannew() resetping_service_ipip61new() enable_ipv45forward() break elif server_type == "2": reset_ping_ipip62irannew() resetping_service_ipip62new() enable_ipv45forward() break elif server_type == "3": reset_ping_ipip63irannew() resetping_service_ipip63new() enable_ipv45forward() break elif server_type == "4": reset_ping_ipip64irannew() resetping_service_ipip64new() enable_ipv45forward() break elif server_type == "5": reset_ping_ipip65irannew() resetping_service_ipip65new() enable_ipv45forward() break elif server_type == "6": reset_ping_ipip66irannew() resetping_service_ipip66new() enable_ipv45forward() break elif server_type == "7": reset_ping_ipip67irannew() resetping_service_ipip67new() enable_ipv45forward() break elif server_type == "8": reset_ping_ipip68irannew() resetping_service_ipip68new() enable_ipv45forward() break elif server_type == "9": reset_ping_ipip69irannew() resetping_service_ipip69new() enable_ipv45forward() break elif server_type == "10": reset_ping_ipip610irannew() resetping_service_ipip610new() enable_ipv45forward() break elif server_type == "11": iran_resetlocal_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menunew() break else: print("Invalid choice.") def reset_local_ip6ip6iransecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_ipip61irannew() resetping_service_ipip61new() enable_ipv45forward() break elif server_type == "2": reset_ping_ipip62irannew() resetping_service_ipip62new() enable_ipv45forward() break elif server_type == "3": reset_ping_ipip63irannew() resetping_service_ipip63new() enable_ipv45forward() break elif server_type == "4": reset_ping_ipip64irannew() resetping_service_ipip64new() enable_ipv45forward() break elif server_type == "5": reset_ping_ipip65irannew() resetping_service_ipip65new() enable_ipv45forward() break elif server_type == "6": iran_resetlocal_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_ip6ip6menunew() break else: print("Invalid choice.") def iran_resetlocal_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_ipip6{i}kharejnew" resetping_service_private_name = f"resetping_service_ipip6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") # gre6menu def reset_local_gre6menunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6kharejmultinew() break elif server_type == "2": reset_local_gre6iranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_gre6secnew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6 + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6kharejsecmultinew() break elif server_type == "2": reset_local_gre6iranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_gre6kharejmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre61kharejnew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre62kharejnew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre63kharejnew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre64kharejnew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre65kharejnew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": reset_ping_gre66kharejnew() resetping_service_gre66new() enable_ipv45forward() break elif server_type == "7": reset_ping_gre67kharejnew() resetping_service_gre67new() enable_ipv45forward() break elif server_type == "8": reset_ping_gre68kharejnew() resetping_service_gre68new() enable_ipv45forward() break elif server_type == "9": reset_ping_gre69kharejnew() resetping_service_gre69new() enable_ipv45forward() break elif server_type == "10": reset_ping_gre610kharejnew() resetping_service_gre610new() enable_ipv45forward() break elif server_type == "11": kharej_resetlocalgre_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6menunew() break else: print("Invalid choice.") def reset_local_gre6kharejsecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre61kharejnew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre62kharejnew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre63kharejnew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre64kharejnew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre65kharejnew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": kharej_resetlocalgre_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6menunew() break else: print("Invalid choice.") def kharej_resetlocalgre_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_gre6{i}irannew" resetping_service_private_name = f"resetping_service_gre6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def reset_local_gre6iranmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre61irannew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre62irannew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre63irannew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre64irannew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre65irannew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": iran_resetlocalgre6_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6menunew() break else: print("Invalid choice.") def iran_resetlocalgre6_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_gre6{i}kharejnew" resetping_service_private_name = f"resetping_service_gre6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") # gretap def reset_local_gre6tapmenunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6TAP Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6tapkharejmultinew() break elif server_type == "2": reset_local_gre6tapiranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_gre6tapsecnew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m GRE6TAP + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_gre6tapkharejsecmultinew() break elif server_type == "2": reset_local_gre6tapiranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_gre6tapkharejmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre6tap1kharejnew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre6tap2kharejnew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre6tap3kharejnew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre6tap4kharejnew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre6tap5kharejnew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": reset_ping_gre6tap6kharejnew() resetping_service_gre66new() enable_ipv45forward() break elif server_type == "7": reset_ping_gre6tap7kharejnew() resetping_service_gre67new() enable_ipv45forward() break elif server_type == "8": reset_ping_gre6tap8kharejnew() resetping_service_gre68new() enable_ipv45forward() break elif server_type == "9": reset_ping_gre6tap9kharejnew() resetping_service_gre69new() enable_ipv45forward() break elif server_type == "10": reset_ping_gre6tap10kharejnew() resetping_service_gre610new() enable_ipv45forward() break elif server_type == "11": kharej_resetlocalgretap_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenunew() break else: print("Invalid choice.") def reset_local_gre6tapkharejsecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre6tap1kharejnew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre6tap2kharejnew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre6tap3kharejnew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre6tap4kharejnew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre6tap5kharejnew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": kharej_resetlocalgretap_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenunew() break else: print("Invalid choice.") def kharej_resetlocalgretap_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_gre6tap{i}irannew" resetping_service_private_name = f"resetping_service_gre6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def reset_local_gre6tapiranmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6TAP \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_gre6tap1irannew() resetping_service_gre61new() enable_ipv45forward() break elif server_type == "2": reset_ping_gre6tap2irannew() resetping_service_gre62new() enable_ipv45forward() break elif server_type == "3": reset_ping_gre6tap3irannew() resetping_service_gre63new() enable_ipv45forward() break elif server_type == "4": reset_ping_gre6tap4irannew() resetping_service_gre64new() enable_ipv45forward() break elif server_type == "5": reset_ping_gre6tap5irannew() resetping_service_gre65new() enable_ipv45forward() break elif server_type == "6": iran_resetlocalgre6tap_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_gre6tapmenunew() break else: print("Invalid choice.") def iran_resetlocalgre6tap_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_gre6tap{i}kharejnew" resetping_service_private_name = f"resetping_service_gre6{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") # private def reset_local_privatemenunew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m 6TO4 Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[10] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_privatekharejmultinew() break elif server_type == "2": reset_local_privateiranmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_privatesecnew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Private + IPSEC Reset Local Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[5] KHAREJ [1] IRAN\033[0m") print("2. \033[92m[1] KHAREJ [5] IRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_local_privatekharejsecmultinew() break elif server_type == "2": reset_local_privateiransecmultinew() break elif server_type == "0": os.system("clear") reset_local_menunew() break else: print("Invalid choice.") def reset_local_privatekharejmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_private1kharejnew() resetping_service_private1new() enable_ipv45forward() break elif server_type == "2": reset_ping_private2kharejnew() resetping_service_private2new() enable_ipv45forward() break elif server_type == "3": reset_ping_private3kharejnew() resetping_service_private3new() enable_ipv45forward() break elif server_type == "4": reset_ping_private4kharejnew() resetping_service_private4new() enable_ipv45forward() break elif server_type == "5": reset_ping_private5kharejnew() resetping_service_private5new() enable_ipv45forward() break elif server_type == "6": reset_ping_private6kharejnew() resetping_service_private6new() enable_ipv45forward() break elif server_type == "7": reset_ping_private7kharejnew() resetping_service_private7new() enable_ipv45forward() break elif server_type == "8": reset_ping_private8kharejnew() resetping_service_private8new() enable_ipv45forward() break elif server_type == "9": reset_ping_private9kharejnew() resetping_service_private9new() enable_ipv45forward() break elif server_type == "10": reset_ping_private10kharejnew() resetping_service_private10new() enable_ipv45forward() break elif server_type == "11": kharej_resetlocalprivate_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_privatemenunew() break else: print("Invalid choice.") def reset_local_privatekharejsecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_private1kharejsecnew() resetping_service_private1new() enable_ipv45forward() break elif server_type == "2": reset_ping_private2kharejsecnew() resetping_service_private2new() enable_ipv45forward() break elif server_type == "3": reset_ping_private3kharejsecnew() resetping_service_private3new() enable_ipv45forward() break elif server_type == "4": reset_ping_private4kharejsecnew() resetping_service_private4new() enable_ipv45forward() break elif server_type == "5": reset_ping_private5kharejsecnew() resetping_service_private5new() enable_ipv45forward() break elif server_type == "6": kharej_resetlocalprivate_qsecnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_privatemenunew() break else: print("Invalid choice.") def kharej_resetlocalprivate_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_private{i}irannew" resetping_service_private_name = f"resetping_service_private{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def kharej_resetlocalprivate_qsecnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_private{i}iransecnew" resetping_service_private_name = f"resetping_service_private{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def reset_local_privateiranmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_private1irannew() resetping_service_private1new() enable_ipv45forward() break elif server_type == "2": reset_ping_private2irannew() resetping_service_private2new() enable_ipv45forward() break elif server_type == "3": reset_ping_private3irannew() resetping_service_private3new() enable_ipv45forward() break elif server_type == "4": reset_ping_private4irannew() resetping_service_private4new() enable_ipv45forward() break elif server_type == "5": reset_ping_private5irannew() resetping_service_private5new() enable_ipv45forward() break elif server_type == "6": iran_resetlocalprivate_qnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_privatemenunew() break else: print("Invalid choice.") def reset_local_privateiransecmultinew(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": reset_ping_private1iransecnew() resetping_service_private1new() enable_ipv45forward() break elif server_type == "2": reset_ping_private2iransecnew() resetping_service_private2new() enable_ipv45forward() break elif server_type == "3": reset_ping_private3iransecnew() resetping_service_private3new() enable_ipv45forward() break elif server_type == "4": reset_ping_private4iransecnew() resetping_service_private4new() enable_ipv45forward() break elif server_type == "5": reset_ping_private5iransecnew() resetping_service_private5new() enable_ipv45forward() break elif server_type == "6": iran_resetlocalprivate_qsecnew() enable_ipv45forward() break elif server_type == "0": os.system("clear") reset_local_privatemenunew() break else: print("Invalid choice.") def iran_resetlocalprivate_qnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_private{i}kharejnew" resetping_service_private_name = f"resetping_service_private{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def iran_resetlocalprivate_qsecnew(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mDoing some stuff\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_ping_private_name = f"reset_ping_private{i}kharejsecnew" resetping_service_private_name = f"resetping_service_private{i}new" if reset_ping_private_name in globals(): globals()[reset_ping_private_name]() else: print(f"\033[91mFunction reset ping doesn't exist.\033[0m") if resetping_service_private_name in globals(): globals()[resetping_service_private_name]() else: print(f"\033[91mFunction reset ping does not exist.\033[0m") def reset_local_privateiransec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6TO4 \033[92m[5IRAN\033[96m [1]Kharej\033[93m Reset Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": enable_reset_private1ir() break elif server_type == "2": enable_reset_private2ir() break elif server_type == "3": enable_reset_private3ir() break elif server_type == "4": enable_reset_private4ir() break elif server_type == "5": enable_reset_private5ir() break elif server_type == "6": iran_resetlocalprivate_q() break elif server_type == "0": os.system("clear") reset_local_privatemenu() break else: print("Invalid choice.") def iran_resetlocalprivate_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): print("\033[93m───────────────────────────────────────\033[0m") display_notification(f"\033[93mServer {i}\033[0m") print("\033[93m───────────────────────────────────────\033[0m") menu_name = "enable_reset_private{}".format(i) globals()[menu_name]() def install_bash(): if not os.path.isfile("/bin/bash"): try: subprocess.run(["sudo", "apt-get", "update"], check=True) subprocess.run(["sudo", "apt-get", "install", "-y", "bash"], check=True) print("\033[92mbash has been installed successfully\033[0m") except subprocess.CalledProcessError as e: print(f"\033[91mError occurred during installation: {e}\033[0m") return False else: print("\033[93mbash is already installed\033[0m") return True def reset_ping_ipip6kharej1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi ip link set dev azumip down ip link delete azumip sleep 30 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/ipip.sh ping -c 1 2002:0db8:1234:a220::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_ipip6iran1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi ip link set dev azumip down ip link delete azumip sleep 30 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/ipip.sh ping -c 1 2002:0db8:1234:a220::1 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_ipip1new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # private def reset_ping_privatekharej1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi sleep 30 /bin/bash /etc/private.sh ping -c 1 2002:831b::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_privateiran1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi sleep 30 /bin/bash /etc/private.sh ping -c 1 2002:831b::1 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_private1new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # gre6 def reset_ping_gre6kharej1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 sleep 30 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre6iran1new(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi down ip link delete azumi ip link set dev azumig6 down ip link delete azumig6 sleep 30 /bin/bash /etc/private.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/gre6.sh ping -c 1 2002:831a::1 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_gre61new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # multi # ipip6 def reset_ping_ipip61kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a020::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumip1 down ip link delete azumip1 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 /bin/bash /etc/ipip1.sh ping -c 1 2002:0db8:1234:a020::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_ipip61irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a020::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumip1 down ip link delete azumip1 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 /bin/bash /etc/ipip1.sh ping -c 1 2002:0db8:1234:a020::1 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_ipip61new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_ipip62kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a120::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumip2 down ip link delete azumip2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 /bin/bash /etc/ipip2.sh ping -c 1 2002:0db8:1234:a120::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_ipip62irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a120::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumip2 down ip link delete azumip2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 /bin/bash /etc/ipip2.sh ping -c 1 2002:0db8:1234:a120::1 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_ipip62new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 3 def reset_ping_ipip63kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumip3 down ip link delete azumip3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 /bin/bash /etc/ipip3.sh ping -c 1 2002:0db8:1234:a220::2 systemctl restart strong-azumi1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_ipip63irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a220::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumip3 down ip link delete azumip3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 /bin/bash /etc/ipip3.sh ping -c 1 2002:0db8:1234:a220::1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_ipip63new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_ipip64kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a320::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumip4 down ip link delete azumip4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 /bin/bash /etc/ipip4.sh ping -c 1 2002:0db8:1234:a320::2 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_ipip64irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a320::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumip4 down ip link delete azumip4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 /bin/bash /etc/ipip4.sh ping -c 1 2002:0db8:1234:a320::1 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_ipip64new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_ipip65kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a420::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumip5 down ip link delete azumip5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 /bin/bash /etc/ipip5.sh ping -c 1 2002:0db8:1234:a420::2 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_ipip65irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a420::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumip5 down ip link delete azumip5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 /bin/bash /etc/ipip5.sh ping -c 1 2002:0db8:1234:a420::1 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_ipip65new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_ipip66kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a520::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumip6 down ip link delete azumip6 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 /bin/bash /etc/ipip6.sh ping -c 1 2002:0db8:1234:a520::2 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_ipip66irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a520::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set azumip6 down ip link delete azumip6 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 /bin/bash /etc/ipip6.sh ping -c 1 2002:0db8:1234:a520::1 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_ipip66new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_ipip67kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a620::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumip7 down ip link delete azumip7 sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 /bin/bash /etc/ipip7.sh ping -c 1 2002:0db8:1234:a620::2 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_ipip67irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a620::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumip7 down sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 /bin/bash /etc/ipip7.sh ping -c 1 2002:0db8:1234:a620::1 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_ipip67new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_ipip68kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a720::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumip8 down ip link delete azumip8 sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 /bin/bash /etc/ipip8.sh ping -c 1 2002:0db8:1234:a720::2 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_ipip68irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a720::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumip8 down ip link delete azumip8 sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 /bin/bash /etc/ipip8.sh ping -c 1 2002:0db8:1234:a720::1 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_ipip68new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_ipip69kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a820::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumip9 down ip link delete azumip9 sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 /bin/bash /etc/ipip9.sh ping -c 1 2002:0db8:1234:a820::2 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_ipip69irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a820::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumip9 down ip link delete azumip9 sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 /bin/bash /etc/ipip9.sh ping -c 1 2002:0db8:1234:a820::1 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_ipip69new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_ipip610kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a920::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumip10 down ip link delete azumip10 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 /bin/bash /etc/ipip10.sh ping -c 1 2002:0db8:1234:a920::2 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_ipip610irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:0db8:1234:a920::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumip10 down ip link delete azumip10 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 /bin/bash /etc/ipip10.sh ping -c 1 2002:0db8:1234:a920::1 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_ipip610new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) # gre6 def reset_ping_gre61kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::2 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre61irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_gre61new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_gre62kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::2 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_gre62irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_gre62new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 2 def reset_ping_gre63kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::2 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_gre63irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_gre63new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_gre64kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 systemctl restart networking sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::2 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_gre64irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::1 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_gre64new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_gre65kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::2 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_gre65irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::1 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_gre65new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_gre66kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::2 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_gre66irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::1 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_gre66new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_gre67kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::2 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_gre67irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::1 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_gre67new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_gre68kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::2 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_gre68irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 systemctl restart networking sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::1 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_gre68new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_gre69kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 systemctl restart networking sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::2 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_gre69irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::1 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_gre69new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_gre610kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::2 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_gre610irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::1 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_gre610new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) # gre6tap def reset_ping_gre6tap1kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 sleep 30 /bin/bash /etc/private1.sh ping -c 1 fd1d:fc98:b73e:b081::2 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::2 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_gre6tap1irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 ip link set dev azumig61 down ip link delete azumig61 sleep 30 /bin/bash /etc/private1.sh ping -c 1 fd1d:fc98:b73e:b081::1 /bin/bash /etc/gre61.sh ping -c 1 2002:801a::1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) # 2 def reset_ping_gre6tap2kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 sleep 30 /bin/bash /etc/private2.sh ping -c 1 fd1d:fc98:b73e:b181::2 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::2 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_gre6tap2irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 ip link set dev azumig62 down ip link delete azumig62 sleep 30 /bin/bash /etc/private2.sh ping -c 1 fd1d:fc98:b73e:b181::1 /bin/bash /etc/gre62.sh ping -c 1 2002:811a::1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) # 2 def reset_ping_gre6tap3kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip lin set dev azumig63 down ip link delete azumig63 sleep 30 /bin/bash /etc/private3.sh ping -c 1 fd1d:fc98:b73e:b281::2 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::2 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_gre6tap3irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 ip link set dev azumig63 down ip link delete azumig63 sleep 30 /bin/bash /etc/private3.sh ping -c 1 fd1d:fc98:b73e:b281::1 /bin/bash /etc/gre63.sh ping -c 1 2002:821a::1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) # 4 def reset_ping_gre6tap4kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 systemctl restart networking sleep 30 /bin/bash /etc/private4.sh ping -c 1 fd1d:fc98:b73e:b381::2 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::2 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_gre6tap4irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 ip link set dev azumig64 down ip link delete azumig64 sleep 30 /bin/bash /etc/private4.sh ping -c 1 fd1d:fc98:b73e:b381::1 /bin/bash /etc/gre64.sh ping -c 1 2002:831a::1 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) # 5 def reset_ping_gre6tap5kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 sleep 30 /bin/bash /etc/private5.sh ping -c 1 fd1d:fc98:b73e:b481::2 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::2 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_gre6tap5irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 ip link set dev azumig65 down ip link delete azumig65 sleep 30 /bin/bash /etc/private5.sh ping -c 1 fd1d:fc98:b73e:b481::1 /bin/bash /etc/gre65.sh ping -c 1 2002:841a::1 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) # 6 def reset_ping_gre6tap6kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 sleep 30 /bin/bash /etc/private6.sh ping -c 1 fd1d:fc98:b73e:b581::2 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::2 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_gre6tap6irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 ip link set dev azumig66 down ip link delete azumig66 sleep 30 /bin/bash /etc/private6.sh ping -c 1 fd1d:fc98:b73e:b581::1 /bin/bash /etc/gre66.sh ping -c 1 2002:851a::1 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) # 7 def reset_ping_gre6tap7kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 sleep 30 /bin/bash /etc/private7.sh ping -c 1 fd1d:fc98:b73e:b681::2 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::2 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_gre6tap7irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 ip link set dev azumig67 down ip link delete azumig67 sleep 30 /bin/bash /etc/private7.sh ping -c 1 fd1d:fc98:b73e:b681::1 /bin/bash /etc/gre67.sh ping -c 1 2002:861a::1 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) # 8 def reset_ping_gre6tap8kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 sleep 30 /bin/bash /etc/private8.sh ping -c 1 fd1d:fc98:b73e:b781::2 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::2 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_gre6tap8irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 ip link set dev azumig68 down ip link delete azumig68 sleep 30 /bin/bash /etc/private8.sh ping -c 1 fd1d:fc98:b73e:b781::1 /bin/bash /etc/gre68.sh ping -c 1 2002:871a::1 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) # 9 def reset_ping_gre6tap9kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 sleep 30 /bin/bash /etc/private9.sh ping -c 1 fd1d:fc98:b73e:b881::2 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::2 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_gre6tap9irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 ip link set dev azumig69 down ip link delete azumig69 sleep 30 /bin/bash /etc/private9.sh ping -c 1 fd1d:fc98:b73e:b881::1 /bin/bash /etc/gre69.sh ping -c 1 2002:881a::1 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) # 10 def reset_ping_gre6tap10kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumg610 down ip link delete azumig610 sleep 30 /bin/bash /etc/private10.sh ping -c 1 fd1d:fc98:b73e:b981::2 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::2 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_gre6tap10irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891a::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 ip link set dev azumig610 down ip link delete azumig610 sleep 30 /bin/bash /etc/private10.sh ping -c 1 fd1d:fc98:b73e:b981::1 /bin/bash /etc/gre610.sh ping -c 1 2002:891a::1 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) # rpivate def reset_ping_private1kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::2 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_private1irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:801b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 systemctl restart networking sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:801b::1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_private1new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) # 2 def reset_ping_private2kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::2 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_private2irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:811b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:811b::1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def resetping_service_private2new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping2.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset2.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset2"]) subprocess.run(["systemctl", "restart", "azumireset2"]) # 2 def reset_ping_private3kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::2 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_private3irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:821b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:821b::1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def resetping_service_private3new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping3.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset3.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset3"]) subprocess.run(["systemctl", "restart", "azumireset3"]) # 4 def reset_ping_private4kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::2 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_private4irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:831b::1 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def resetping_service_private4new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping4.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset4.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset4"]) subprocess.run(["systemctl", "restart", "azumireset4"]) # 5 def reset_ping_private5kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::2 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_private5irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:841b::1 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def resetping_service_private5new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping5.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset5.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset5"]) subprocess.run(["systemctl", "restart", "azumireset5"]) # 6 def reset_ping_private6kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::2 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def reset_ping_private6irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi6 down ip link delete azumi6 sleep 30 /bin/bash /etc/private6.sh ping -c 1 2002:851b::1 fi sleep 5 done """ with open("/etc/resetbasedonping6.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping6.sh", 0o755) def resetping_service_private6new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping6.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset6"]) subprocess.run(["systemctl", "restart", "azumireset6"]) # 7 def reset_ping_private7kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::2 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def reset_ping_private7irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi7 down ip link delete azumi7 sleep 30 /bin/bash /etc/private7.sh ping -c 1 2002:861b::1 fi sleep 5 done """ with open("/etc/resetbasedonping7.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping7.sh", 0o755) def resetping_service_private7new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping7.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset7.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset7"]) subprocess.run(["systemctl", "restart", "azumireset7"]) # 8 def reset_ping_private8kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::2 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def reset_ping_private8irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi8 down ip link delete azumi8 sleep 30 /bin/bash /etc/private8.sh ping -c 1 2002:871b::1 fi sleep 5 done """ with open("/etc/resetbasedonping8.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping8.sh", 0o755) def resetping_service_private8new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping8.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset8.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset8"]) subprocess.run(["systemctl", "restart", "azumireset8"]) # 9 def reset_ping_private9kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::2 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def reset_ping_private9irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:881b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi9 down ip link delete azumi9 sleep 30 /bin/bash /etc/private9.sh ping -c 1 2002:881b::1 fi sleep 5 done """ with open("/etc/resetbasedonping9.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping9.sh", 0o755) def resetping_service_private9new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping9.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset9.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset9"]) subprocess.run(["systemctl", "restart", "azumireset9"]) # 10 def reset_ping_private10kharejnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::2 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def reset_ping_private10irannew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:891b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi10 down ip link delete azumi10 sleep 30 /bin/bash /etc/private10.sh ping -c 1 2002:891b::1 fi sleep 5 done """ with open("/etc/resetbasedonping10.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping10.sh", 0o755) def resetping_service_private10new(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping10.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset10.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset10"]) subprocess.run(["systemctl", "restart", "azumireset10"]) def reset_ping_private1kharejsecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:831b::2 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def reset_ping_private1iransecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:831b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi1 down ip link delete azumi1 sleep 30 /bin/bash /etc/private1.sh ping -c 1 2002:831b::1 fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) # 2 def reset_ping_private2kharejsecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:841b::2 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) def reset_ping_private2iransecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:841b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi2 down ip link delete azumi2 sleep 30 /bin/bash /etc/private2.sh ping -c 1 2002:841b::1 fi sleep 5 done """ with open("/etc/resetbasedonping2.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping2.sh", 0o755) # 3 def reset_ping_private3kharejsecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:851b::2 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) def reset_ping_private3iransecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:851b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi3 down ip link delete azumi3 sleep 30 /bin/bash /etc/private3.sh ping -c 1 2002:851b::1 fi sleep 5 done """ with open("/etc/resetbasedonping3.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping3.sh", 0o755) # 4 def reset_ping_private4kharejsecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:861b::2 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) def reset_ping_private4iransecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:861b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi4 down ip link delete azumi4 sleep 30 /bin/bash /etc/private4.sh ping -c 1 2002:861b::1 fi sleep 5 done """ with open("/etc/resetbasedonping4.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping4.sh", 0o755) # 5 def reset_ping_private5kharejsecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::2 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:871b::2 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def reset_ping_private5iransecnew(): script_content = f"""#!/bin/bash while true; do ping -c 2 2002:871b::1 >/dev/null 2>&1 if [ $? -ne 0 ]; then ip link set dev azumi5 down ip link delete azumi5 sleep 30 /bin/bash /etc/private5.sh ping -c 1 2002:871b::1 fi sleep 5 done """ with open("/etc/resetbasedonping5.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping5.sh", 0o755) def name_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mTunnel names\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[97mThis is a guide for tunnel names:\033[0m") print( ". \033[93mTunnel interface name : azumi \033[97m=\033[92m Sit or 6to4\033[0m" ) print( ". \033[93mTunnel interface name : azumip \033[97m=\033[92m IP6IP6\033[0m" ) print(". \033[93mTunnel interface name : azumig \033[97m=\033[92m GRE\033[0m") print( ". \033[93mTunnel interface name : azumig6 \033[97m=\033[92m GRE6 or GRE6tap\033[0m" ) print( ". \033[93mTunnel interface name : azumigen \033[97m=\033[92m Geneve\033[0m" ) print( ". \033[93mTunnel interface name : azumiespn \033[97m=\033[92m Erspan\033[0m" ) print( ". \033[93mTunnel interface name : Tun0 - Tun1 \033[97m=\033[92m ICMP Tunnel\033[0m" ) print(". \033[93mTunnel interface name : icmp \033[97m=\033[92m Hans\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[97mSome more Examples:\033[0m") print( ". \033[93mInterface names : azumi + azumig6 \033[97m=\033[92m Privateip + GRE6 | GRE6tap\033[0m" ) print( ". \033[93mInterface names : azumi + azumig6 + azumigen \033[97m=\033[92m Privateip + GRE6 | GRE6tap + Geneve\033[0m" ) print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter 0 to get back to the main menu: \033[0m") if choice == "0": clear() multiserver_mnu() break else: print("Invalid choice.") def name3_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mTunnel names\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[97mThis is a guide for tunnel names:\033[0m") print( ". \033[93mTunnel interface name : vxlan \033[97m=\033[92m vxlan\033[0m" ) print( ". \033[93mTunnel interface name : azumi \033[97m=\033[92m Sit or 6to4\033[0m" ) print( ". \033[93mTunnel interface name : azumip \033[97m=\033[92m IP6IP6\033[0m" ) print(". \033[93mTunnel interface name : azumig \033[97m=\033[92m GRE\033[0m") print( ". \033[93mTunnel interface name : azumig6 \033[97m=\033[92m GRE6 or GRE6tap\033[0m" ) print( ". \033[93mTunnel interface name : azumigen \033[97m=\033[92m Geneve\033[0m" ) print( ". \033[93mTunnel interface name : azumiespn \033[97m=\033[92m Erspan\033[0m" ) print( ". \033[93mTunnel interface name : Tun0 - Tun1 \033[97m=\033[92m ICMP Tunnel\033[0m" ) print(". \033[93mTunnel interface name : icmp \033[97m=\033[92m Hans\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter 0 to get back to the main menu: \033[0m") if choice == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def name2_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mTunnel names\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[97mThis is a guide for tunnel names:\033[0m") print( ". \033[93miran1config3 \033[97m=\033[92m Sit | IRAN Server 1 Kharej 3\033[0m" ) print( ". \033[93miran2config1 \033[97m=\033[92m Sit | IRAN Server 2 Kharej 1\033[0m" ) print( ". \033[93miran5config4 \033[97m=\033[92m Sit | IRAN Server 5 Kharej 4\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter 0 to get back to the main menu: \033[0m") if choice == "0": clear() multi2server_mnu() break else: print("Invalid choice.") def status_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mStatus\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1 \033[93mSingle Status\033[0m") print("2 \033[92mMulti Status\033[0m") print("3 \033[92mIsatap Status\033[0m") print("4 \033[92mWireguard Status\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter 0 to get back to the main menu: \033[0m") if choice == "1": clear() single_status() break elif choice == "2": clear() multi_status() break elif choice == "3": clear() isatap_status() break elif choice == "4": clear() wireguard_status() break if choice == "0": clear() main_menu() break else: print("Invalid choice.") def bibi_codel(): choice = input( "\033[93mDo you want to install BBR Codel \033[92moptimized \033[93mfor \033[96mIPSec\033[93m? \033[93m(\033[92mYes\033[93m/\033[91mNo\033[93m): \033[0m" ).lower() if choice in ["y", "yes"]: subprocess.run( [ "bash", "-c", "python3 <(curl -Ls https://raw.githubusercontent.com/kalilovers/LightKnightBBR/main/bbr.py --ipv4)", ] ) elif choice in ["n", "no"]: pass else: print("\033[91mWrong choice! Plz try again..\033[0m") def restart_forced_strongazumi(): subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL ) def multi2server_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mMulti 2 Server\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]KHAREJ [5]IRAN Methods\033[0m") print("2. \033[93mISATAP Server & Client\033[0m") print("3. \033[92mWireguard Server & Client\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": iran5_kharej10_mnu() break elif choice == "2": isatap_mnu() break elif choice == "3": wireguard_allinone_mnu() break elif choice == "0": clear() main_menu() break else: print("Invalid choice.") ##wireguard start def singleserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mSingle Server\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[36mExtra Native IPV6\033[0m") print("2. \033[93mEdit \033[92mMTU\033[0m") print("3. \033[92mGeneve UDP \033[0m") print("4. \033[96mGeneve + IPsec\033[0m") print("5. \033[93mICMP + IPsec\033[0m") print("42.\033[97mERSPAN [test][Some of them will be removed]\033[0m") print("6. \033[96mIP6IP6\033[0m") print("7. \033[92mIP6IP6 + IPSec\033[0m") print("8. \033[93mPrivate IP\033[0m") print("9. \033[96mPrivate IP + IPSec\033[0m") print("10. \033[92mGRE\033[0m") print("11. \033[96mGRE6\033[0m") print("12. \033[93mGRE6 + IPSec\033[0m") print("13. \033[97mGRE6tap\033[0m") print("14. \033[96mGRE6tap + IPSec\033[0m") print("15. \033[93m6TO4 \033[0m") print("16. \033[92m6TO4 \033[97m[Anycasnt] \033[0m") print("17. \033[93mVxlan \033[0m") print("18. \033[96mVxlan + IPsec \033[0m") print("19. \033[91mUninstall\033[0m") print("q. \033[91mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": Native_menu() break elif choice == "2": mtu_menu() break elif choice == "3": genz_ip() break elif choice == "42": espn_menu() break elif choice == "4": gen4_ipsec_mnu() break elif choice == "5": icmp_ip_mnu() break elif choice == "6": ipip_menu() break elif choice == "7": ipip__ipsec_menu() break elif choice == "8": private_ip_menu() break elif choice == "9": private_ipsec() break elif choice == "10": gre_menu() break elif choice == "11": gre6_menu() break elif choice == "12": gre6sec_menu() break elif choice == "13": gre6tapsingle_mnu() break elif choice == "14": gre6tapsec_mnu() break elif choice == "15": i6to4_no() break elif choice == "16": i6to4_any() break elif choice == "17": vxlan_choose_regular() break elif choice == "18": vxlan_choose_ipsecmnu() break elif choice == "19": remove_menu() break elif choice == "q": clear() main_menu() break else: print("Invalid choice.") def multiserver_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mMulti Server\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("0 \033[92mTunnel Names Guide \033[97mMENU\033[0m") print("1. \033[96mIP6IP6 Multiple Servers\033[0m") print("2. \033[93mIP6IP6 + IPSec Multiple Servers\033[0m") print("3. \033[92mGRE6 Multiple Servers\033[0m") print("4. \033[96mGRE6 + IPSsec Multiple Servers\033[0m") print("5. \033[93m6tO4 Multiple Servers\033[0m") print("6. \033[96m6tO4 + IPsec Multiple Servers\033[0m") print("7. \033[92mGre6tap Multiple Servers\033[0m") print("8. \033[93mGeneve Multiple Servers\033[0m") print("9. \033[96mAnycast Multiple Servers\033[0m") print("10. \033[93mEdit \033[92mServers\033[0m") print("11. \033[97mEdit \033[92mMTU\033[0m") print("12. \033[91mUninstall\033[0m") print("q. \033[91mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": name_mnu() break elif choice == "1": ip6_mnu_ip() break elif choice == "2": ip6_mnu_ipsec() break elif choice == "3": gre6_mnu_ip() break elif choice == "4": gre6_mnu_ipsec() break elif choice == "5": priv_mnu_ip() break elif choice == "6": priv_mnu_ipsec() break elif choice == "7": gre6tapmulti_mnu() break elif choice == "8": gen_multi_menuz() break elif choice == "9": i6to41_any() break elif choice == "10": edit_server() break elif choice == "11": mtu2_menu() break elif choice == "12": remove2_menu() break elif choice == "q": clear() main_menu() break else: print("Invalid choice.") ## gretapsec def gre6tapsec_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap + IPSec\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPV4 + IPSec \033[0m") print("2. \033[93mGRE6tap Native + IPSec \033[0m") print("3. \033[96mIPsec Reset Timer \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnusingle() gretap4sec() break elif server_type == "2": gre6_reset_rmvmnusingle() gretapnsec() break elif server_type == "3": choose_reset() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def gretapnsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative \033[93m+\033[92m Gretap6 + IPSec \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapsec_k() break elif server_type == "2": gre6tapsec_i() break elif server_type == "3": clear() gre6tapsec_mnu() break else: print("Invalid choice.") def azumi_gretap_k(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_gretap_ir(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def gre6tapsec_k(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gretap_k(psk) kharej_gre6tap_tunnel() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tapsec_i(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gretap_ir(psk) iran_gre6tap_tunnel() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ## gre6tap ip4 def gretap4sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[96mGRE6tap + IPSec \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6sec_kharej() break elif server_type == "2": gre6tap6sec_iran() break elif server_type == "3": clear() gre6tapsec_mnu() break else: print("Invalid choice.") def gre6tap6sec_kharej(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gretap_k(psk) kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6sec_iran(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gretap_ir(psk) iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ## gre6tap simple def gre6tapsingle_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPV4 \033[0m") print("2. \033[93mGRE6tap Native \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnusingle() gretap4() break elif server_type == "2": gre6_reset_rmvmnusingle() gretapn() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def gretapn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_k() break elif server_type == "2": gre6tap_i() break elif server_type == "3": clear() gre6tapsingle_mnu() break else: print("Invalid choice.") def gre6tapk_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def kharej_gre6tap_tunnel(): global local_ip, remote_ip gre6tapk_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def gre6tap_k(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def iran_gre6tap_tunnel(): global local_ip, remote_ip gre6tapi_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gre6tap_i(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ## gre6tap ip4 def gretap4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGRE6tap \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6_kharej() break elif server_type == "2": gre6tap6_iran() break elif server_type == "3": clear() gre6tapsingle_mnu() break else: print("Invalid choice.") def gre6tap6_kharej(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iran(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def espn_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mERSPAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan \033[0m") print("2. \033[93mErspan + \033[92mNative \033[0m") print("3. \033[96mErspan + ip6ip6 [NEW] \033[0m") print("4. \033[93mErspan + Gretap6 \033[0m") print("5. \033[92mErspan + IPsec Tunnels \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip4_spn() break elif server_type == "2": ip6_spn() break elif server_type == "3": spn_ipip6() break elif server_type == "4": spn_gre6tap() break elif server_type == "5": ipsec_mnu() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") # simple ip4 & native ipip6 def spn_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mIP6IP6 \033[93m+ \033[96mErspan\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1 \033[0m") print("2. \033[92mMethod 2 \033[0m") print("3. \033[93mMethod 3 Native \033[0m") print("0. \033[91mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_ipip4() break elif server_type == "2": spn_m2_sit4() break elif server_type == "3": spn_ipipn() break elif server_type == "0": clear() main_menu() break else: print("Invalid choice.") # native ipip spn def spn_ipipn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mERSPAN + \033[96mNative \033[93m+\033[92m IP6IP6 \033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipip_gre6k() break elif server_type == "2": spn_ipip_gre6i() break elif server_type == "3": clear() spn_ipip6() break else: print("Invalid choice.") def spn_ipip_gre6k(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipip_grek1() break elif server_type == "2": spn_ipip_grek2() break else: print("Invalid choice.") def ipip6rn_kharej1_tunnel(): global local_ip, remote_ip file_path = "/etc/sys.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip6 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/sys.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def ip6ip6_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/sys.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/sys.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ipip6rn_kharej1(): ipip6rn_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() ip6ip6_cronjob() def spn_ipip_grek1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ipip6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ipip_grek2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ipip6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran def ipip6rn_iran1_tunnel(): global local_ip, remote_ip file_path = "/etc/sys.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip6 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/sys.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def ipip6rn_iran1(): ipip6rn_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() ip6ip6_cronjob() def spn_ipip_gre6i(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipip_grei1() break elif server_type == "2": spn_ipip_grei2() break else: print("Invalid choice.") def spn_ipip_grei1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ipip6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_ipip_grei2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ipip6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # ip4 ip6ip6 erspan def spn_ipip4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[96mMethod 1 \033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipip_kharej() break elif server_type == "2": spn_ipip_iran() break elif server_type == "3": clear() spn_ipip6() break else: print("Invalid choice.") def spn_ipip_kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_ipipkh() def spn_ipipkh(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipipk_1() break elif server_type == "2": spn_ipipk_2() break else: print("Invalid choice.") def ip6ip64_kharej(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mIP6IP6\033[97m tunnel: " ) ) ipip64_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() ip6ip6_cronjob() # espn_gre def kharej1_ip6ip64_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mServer Configuration Completed!\033[0m") ip6ip64_kharej() sleep(1) ## def spn_ipipk_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ipipk_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ipip_iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn2_ipipir() def spn2_ipipir(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipipi_1() break elif server_type == "2": spn_ipipi_2() break else: print("Invalid choice.") ## prequisite def ip6ip64_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/sys.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/sys.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ip6ip64_iran(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mIP6IP6\033[97m tunnel: " ) ) ip6ip64_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() ip6ip6_cronjob() ## ip6ip6 erspan iran def iran1_ip6ip64_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) ip6ip64_iran() sleep(1) display_checkmark("\033[92mServer Configuration Completed!\033[0m") ## def spn_ipipi_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_ipipi_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## method2 # ip4 ipip erspan def spn_m2_ipip4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[92mMethod 1 \033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_ipip_kharej() break elif server_type == "2": spn_m2_ipip_iran() break elif server_type == "3": clear() spn_m2_ipip6() break else: print("Invalid choice.") def spn_m2_ipip_kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_m2_ipipkh() def spn_m2_ipipkh(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_ipipk_1() break elif server_type == "2": spn_m2_ipipk_2() break else: print("Invalid choice.") ## method2 menu def spn_m2_sit4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[92mMethod 2 \033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_sit_kharej() break elif server_type == "2": spn_m2_sit_iran() break elif server_type == "3": clear() spn_m2_ipip6() break else: print("Invalid choice.") def spn_m2_sit_kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_m2_sitkh() def spn_m2_sitkh(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_sitk_1() break elif server_type == "2": spn_m2_sitk_2() break else: print("Invalid choice.") # prequisite def ipip64_m2_tunnel(): global local_ip, remote_ip file_path = "/etc/sys.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo '/sbin/modprobe fou' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumip6 type ipip remote {remote_ip} local {local_ip} encap fou encap-sport auto encap-dport 5555' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add 192.168.1.1/30 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def ip6ip64_m2_kharej(): ipip64_m2_tunnel() ip_address = "192.168.1.2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() ip6ip6_cronjob() # espn_sit def kharej1_m2_ip6ip64_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "link", "add", "name", "azumi", "type", "sit", "remote", remote_ip, "local", local_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "addr", "add", "192.168.1.1/30", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip link add name azumi type sit remote {remote_ip} local {local_ip}\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add 192.168.1.1/30 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="192.168.1.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_checkmark("\033[92mServer Configuration Completed!\033[0m") ## for ipip def spn_m2_ipipk_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6ip64_m2_kharej() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.1", "remote", "192.168.1.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.1 remote 192.168.1.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## for sit def spn_m2_sitk_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_m2_sitk_1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.1", "remote", "192.168.1.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.1 remote 192.168.1.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ##ipv6 for ipip def spn_m2_ipipk_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6ip64_m2_kharej() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.1", "remote", "192.168.1.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.1 remote 192.168.1.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ##ipv6 for sit def spn_m2_sitk_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_m2_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.1", "remote", "192.168.1.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.1 remote 192.168.1.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran side def spn_m2_ipip_iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn2_m2_ipipir() def spn2_m2_ipipir(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_ipipi_1() break elif server_type == "2": spn_m2_ipipi_2() break else: print("Invalid choice.") # method 2 iran ip6 erspan def spn_m2_sit_iran(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn2_m2_sitir() def spn2_m2_sitir(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_m2_siti_1() break elif server_type == "2": spn_m2_siti_2() break else: print("Invalid choice.") ## prequisite ipip def ip6ip64_m2_iran_tunnel(): global local_ip, remote_ip file_path = "/etc/sys.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo '/sbin/modprobe fou' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumip6 type ipip remote {remote_ip} local {local_ip} encap fou encap-sport auto encap-dport 5555' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add 192.168.1.2/30 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) # prequisite sit def ip6ip64_m2_iran(): global local_ip, remote_ip ip6ip64_m2_iran_tunnel() ip_address = "192.168.1.1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() ip6ip6_cronjob() ## IP6IP6 erspan iran def iran1_m2_ip6ip64_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "link", "add", "name", "azumi", "type", "sit", "remote", remote_ip, "local", local_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "addr", "add", "192.168.1.2/30", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip link add name azumi type sit remote {remote_ip} local {local_ip}\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add 192.168.1.2/30 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") sleep(1) script_content1 = """#!/bin/bash ip_address="192.168.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_checkmark("\033[92mServer Configuration Completed!\033[0m") ## method2 ipip erspan6 def spn_m2_ipipi_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6ip64_m2_iran() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.2", "remote", "192.168.1.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.2 remote 192.168.1.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## method3 sit erspan4 def spn_m2_siti_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_m2_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.2", "remote", "192.168.1.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.2 remote 192.168.1.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_m2_ipipi_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6ip64_m2_iran() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.2", "remote", "192.168.1.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.2 remote 192.168.1.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") #robot# def robot_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mSingle\033[0m") print("2 \033[92mMulti \033[97m[Working on it]\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_mnu() break elif choice == "2": break elif choice == "0": clear() main_menu() break else: print("Invalid choice.") def robot_single_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mSingle\033[93m Robot Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mWhich one to edit:\033[0m") print("1. \033[92m IP6IP6\033[0m") print("2. \033[93m IP6IP6 + IPSEC\033[0m") print("3. \033[92m GRE6\033[0m") print("4. \033[93m GRE6 + IPSEC\033[0m") print("5. \033[92m GRE6TAP \033[96m [IPV4]\033[0m") print("6. \033[93m GRE6TAP \033[96m [IPV4] + IPSEC\033[0m") print("7. \033[92m Private\033[0m") print("8. \033[93m Private + IPSEC\033[0m") print("9. \033[92m Geneve UDP\033[0m") print("10. \033[93m Geneve UDP + IPSEC\033[0m") print("11. \033[92m Geneve GRE6\033[0m") print("12. \033[93m Geneve GRE6 + IPSEC\033[0m") print("13. \033[91m Remove\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robotreconfig_single_ip6ip6() break elif choice == "2": robotreconfig_single_ip6ip6sec() break elif choice == "3": robotreconfig_single_gre6() break elif choice == "4": robotreconfig_single_gre6sec() break elif choice == "5": robotreconfig_single_gre6tap() break elif choice == "6": robotreconfig_single_gre6tapsec() break elif choice == "7": robotreconfig_single_private() break elif choice == "8": robotreconfig_single_privatesec() break elif choice == "9": robotreconfig_single_geneve() break elif choice == "10": robotreconfig_single_genevesec() break elif choice == "11": robotreconfig_single_gengre() break elif choice == "12": robotreconfig_single_gengresec() break elif choice == "13": remove() break elif choice == "0": clear() robot_menu() break else: print("Invalid choice.") def robotreconfig_single_ip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mIP6IP6 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_ip6ip6_kharej() break elif choice == "2": robot_single_ip6ip6_iran() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single ip6ip6 def singleip6ip6_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '6' inputs['private_kharej_ip'] = '2002:0db8:1234:a220::1' inputs['private_iran_ip'] = '2002:0db8:1234:a220::2' inputs['ip6ip6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_ip6ip6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '1' return inputs def generate_bash_script_singleip6ip6_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_ip6ip6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_ip6ip6.sh" service_path = "/etc/systemd/system/robot_ip6ip6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_ip6ip6.service"]) subprocess.run(["systemctl", "restart", "robot_ip6ip6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleip6ip6kharej(inputs): with open("/usr/local/bin/single_ip6ip6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleip6ip6kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_ip6ip6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_ip6ip6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip6ip6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_ip6ip6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_ip6ip6_kharej(): inputs = singleip6ip6_kharejuser_input() store_inputs_singleip6ip6kharej(inputs) generate_bash_script_singleip6ip6_kharej(inputs) create_script_singleip6ip6kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single ip6ip6 def singleip6ip6_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '6' inputs['private_kharej_ip'] = '2002:0db8:1234:a220::1' inputs['private_iran_ip'] = '2002:0db8:1234:a220::2' inputs['ip6ip6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_ip6ip6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '1' return inputs def generate_bash_script_singleip6ip6_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_ip6ip6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_ip6ip6.sh" service_path = "/etc/systemd/system/robot_ip6ip6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_ip6ip6.service"]) subprocess.run(["systemctl", "restart", "robot_ip6ip6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleip6ip6iran(inputs): with open("/usr/local/bin/single_ip6ip6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleip6ip6iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_ip6ip6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_ip6ip6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip6ip6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_ip6ip6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_ip6ip6_iran(): inputs = singleip6ip6_iranuser_input() store_inputs_singleip6ip6iran(inputs) generate_bash_script_singleip6ip6_iran(inputs) create_script_singleip6ip6iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #robot ip6ip6 ipsec single def robotreconfig_single_ip6ip6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mIP6IP6 IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_ip6ip6_kharejsec() break elif choice == "2": robot_single_ip6ip6_iransec() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single ip6ip6 def singleip6ip6_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '7' inputs['private_kharej_ip'] = '2002:0db8:1234:a220::1' inputs['private_iran_ip'] = '2002:0db8:1234:a220::2' inputs['ip6ip6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_ip6ip6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '2' return inputs def generate_bash_script_singleip6ip6_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_ip6ip6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_ip6ip6sec.sh" service_path = "/etc/systemd/system/robot_ip6ip6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_ip6ip6sec.service"]) subprocess.run(["systemctl", "restart", "robot_ip6ip6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleip6ip6kharejsec(inputs): with open("/usr/local/bin/single_ip6ip6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleip6ip6kharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_ip6ip6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_ip6ip6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip6ip6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_ip6ip6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_ip6ip6_kharejsec(): inputs = singleip6ip6_kharejuser_inputsec() store_inputs_singleip6ip6kharejsec(inputs) generate_bash_script_singleip6ip6_kharejsec(inputs) create_script_singleip6ip6kharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single ip6ip6 def singleip6ip6_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '7' inputs['private_kharej_ip'] = '2002:0db8:1234:a220::1' inputs['private_iran_ip'] = '2002:0db8:1234:a220::2' inputs['ip6ip6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_ip6ip6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '2' return inputs def generate_bash_script_singleip6ip6_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_ip6ip6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_ip6ip6sec.sh" service_path = "/etc/systemd/system/robot_ip6ip6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_ip6ip6sec.service"]) subprocess.run(["systemctl", "restart", "robot_ip6ip6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleip6ip6iransec(inputs): with open("/usr/local/bin/single_ip6ip6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleip6ip6iransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_ip6ip6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_ip6ip6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip6ip6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_ip6ip6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_ip6ip6_iransec(): inputs = singleip6ip6_iranuser_inputsec() store_inputs_singleip6ip6iransec(inputs) generate_bash_script_singleip6ip6_iransec(inputs) create_script_singleip6ip6iransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #gre6 def robotreconfig_single_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGRE6 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gre6_kharej() break elif choice == "2": robot_single_gre6_iran() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single gre6 def singlegre6_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '11' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '6' return inputs def generate_bash_script_singlegre6_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6.sh" service_path = "/etc/systemd/system/robot_gre6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6.service"]) subprocess.run(["systemctl", "restart", "robot_gre6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6kharej(inputs): with open("/usr/local/bin/single_gre6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6_kharej(): inputs = singlegre6_kharejuser_input() store_inputs_singlegre6kharej(inputs) generate_bash_script_singlegre6_kharej(inputs) create_script_singlegre6kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single gre6 def singlegre6_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '11' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '6' return inputs def generate_bash_script_singlegre6_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6.sh" service_path = "/etc/systemd/system/robot_gre6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6.service"]) subprocess.run(["systemctl", "restart", "robot_gre6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6iran(inputs): with open("/usr/local/bin/single_gre6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6_iran(): inputs = singlegre6_iranuser_input() store_inputs_singlegre6iran(inputs) generate_bash_script_singlegre6_iran(inputs) create_script_singlegre6iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #robot gre6 ipsec single def robotreconfig_single_gre6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGRE6 IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gre6_kharejsec() break elif choice == "2": robot_single_gre6_iransec() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single gre6 def singlegre6_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '12' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '7' return inputs def generate_bash_script_singlegre6_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6sec.sh" service_path = "/etc/systemd/system/robot_gre6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6sec.service"]) subprocess.run(["systemctl", "restart", "robot_gre6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6kharejsec(inputs): with open("/usr/local/bin/single_gre6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6kharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6_kharejsec(): inputs = singlegre6_kharejuser_inputsec() store_inputs_singlegre6kharejsec(inputs) generate_bash_script_singlegre6_kharejsec(inputs) create_script_singlegre6kharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single gre6 def singlegre6_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '12' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '7' return inputs def generate_bash_script_singlegre6_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6sec.sh" service_path = "/etc/systemd/system/robot_gre6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6sec.service"]) subprocess.run(["systemctl", "restart", "robot_gre6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6iransec(inputs): with open("/usr/local/bin/single_gre6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6iransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6_iransec(): inputs = singlegre6_iranuser_inputsec() store_inputs_singlegre6iransec(inputs) generate_bash_script_singlegre6_iransec(inputs) create_script_singlegre6iransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #gre6tap ipv4 def robotreconfig_single_gre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGRE6tap \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gre6tap_kharej() break elif choice == "2": robot_single_gre6tap_iran() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single gre6tap def singlegre6tap_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '13' inputs['ipv4_or_ipv6'] = '1' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '8' return inputs def generate_bash_script_singlegre6tap_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6.sh" service_path = "/etc/systemd/system/robot_gre6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6.service"]) subprocess.run(["systemctl", "restart", "robot_gre6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6tapkharej(inputs): with open("/usr/local/bin/single_gre6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6tapkharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ipv4_or_ipv6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6tap_kharej(): inputs = singlegre6tap_kharejuser_input() store_inputs_singlegre6tapkharej(inputs) generate_bash_script_singlegre6tap_kharej(inputs) create_script_singlegre6tapkharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single gre6tap def singlegre6tap_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '13' inputs['ipv4_or_ipv6'] = '1' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '8' return inputs def generate_bash_script_singlegre6tap_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6.sh" service_path = "/etc/systemd/system/robot_gre6.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6.service"]) subprocess.run(["systemctl", "restart", "robot_gre6.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6tapiran(inputs): with open("/usr/local/bin/single_gre6_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6tapiran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ipv4_or_ipv6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6tap_iran(): inputs = singlegre6tap_iranuser_input() store_inputs_singlegre6tapiran(inputs) generate_bash_script_singlegre6tap_iran(inputs) create_script_singlegre6tapiran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #robot gre6tap ipsec single def robotreconfig_single_gre6tapsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGRE6tap IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gre6tap_kharejsec() break elif choice == "2": robot_single_gre6tap_iransec() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single gre6tap def singlegre6tap_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '14' inputs['ipv4_or_ipv6'] = '1' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '9' return inputs def generate_bash_script_singlegre6tap_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6sec.sh" service_path = "/etc/systemd/system/robot_gre6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6sec.service"]) subprocess.run(["systemctl", "restart", "robot_gre6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6tapkharejsec(inputs): with open("/usr/local/bin/single_gre6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6tapkharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ipv4_or_ipv6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6tap_kharejsec(): inputs = singlegre6tap_kharejuser_inputsec() store_inputs_singlegre6tapkharejsec(inputs) generate_bash_script_singlegre6tap_kharejsec(inputs) create_script_singlegre6tapkharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single gre6tap def singlegre6tap_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '14' inputs['ipv4_or_ipv6'] = '1' inputs['private_kharej_ip'] = '2002:831a::1' inputs['private_iran_ip'] = '2002:831a::2' inputs['gre6_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['change_default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '9' return inputs def generate_bash_script_singlegre6tap_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gre6sec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gre6sec.sh" service_path = "/etc/systemd/system/robot_gre6sec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gre6sec.service"]) subprocess.run(["systemctl", "restart", "robot_gre6sec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegre6tapiransec(inputs): with open("/usr/local/bin/single_gre6sec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegre6tapiransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gre6sec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gre6sec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ipv4_or_ipv6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['gre6_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gre6tap_iransec(): inputs = singlegre6tap_iranuser_inputsec() store_inputs_singlegre6tapiransec(inputs) generate_bash_script_singlegre6tap_iransec(inputs) create_script_singlegre6tapiransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #private def robotreconfig_single_private(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mPrivate \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_private_kharej() break elif choice == "2": robot_single_private_iran() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single private def singleprivate_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '8' inputs['private_kharej_ip'] = '2002:831b::1' inputs['private_iran_ip'] = '2002:831b::2' inputs['private_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_6to4'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '10' return inputs def generate_bash_script_singleprivate_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_private.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_private.sh" service_path = "/etc/systemd/system/robot_private.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_private.service"]) subprocess.run(["systemctl", "restart", "robot_private.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleprivatekharej(inputs): with open("/usr/local/bin/single_private_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleprivatekharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_private.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_private_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['private_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_private_kharej(): inputs = singleprivate_kharejuser_input() store_inputs_singleprivatekharej(inputs) generate_bash_script_singleprivate_kharej(inputs) create_script_singleprivatekharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single private def singleprivate_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '8' inputs['private_kharej_ip'] = '2002:831b::1' inputs['private_iran_ip'] = '2002:831b::2' inputs['private_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['additional_ips'] = input("\033[93mHow many \033[92madditional IPs \033[93mdo you need?\033[0m ") inputs['change_default_route'] = 'n' inputs['set_mtu_6to4'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '10' return inputs def generate_bash_script_singleprivate_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_private.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_private.sh" service_path = "/etc/systemd/system/robot_private.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_private.service"]) subprocess.run(["systemctl", "restart", "robot_private.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleprivateiran(inputs): with open("/usr/local/bin/single_private_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleprivateiran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_private.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_private_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['private_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additional_ips']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_private_iran(): inputs = singleprivate_iranuser_input() store_inputs_singleprivateiran(inputs) generate_bash_script_singleprivate_iran(inputs) create_script_singleprivateiran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #robot private ipsec single def robotreconfig_single_privatesec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mPrivate IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_private_kharejsec() break elif choice == "2": robot_single_private_iransec() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") #kharej robot reconfig single private def singleprivate_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '9' inputs['private_kharej_ip'] = '2002:831b::1' inputs['private_iran_ip'] = '2002:831b::2' inputs['private_method'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['change_default_route'] = 'n' inputs['set_mtu_6to4'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '11' return inputs def generate_bash_script_singleprivate_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_privatesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_privatesec.sh" service_path = "/etc/systemd/system/robot_privatesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_privatesec.service"]) subprocess.run(["systemctl", "restart", "robot_privatesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleprivatekharejsec(inputs): with open("/usr/local/bin/single_privatesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleprivatekharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_privatesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_privatesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['private_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_private_kharejsec(): inputs = singleprivate_kharejuser_inputsec() store_inputs_singleprivatekharejsec(inputs) generate_bash_script_singleprivate_kharejsec(inputs) create_script_singleprivatekharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single private def singleprivate_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '9' inputs['private_kharej_ip'] = '2002:831b::1' inputs['private_iran_ip'] = '2002:831b::2' inputs['private_method'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['change_default_route'] = 'n' inputs['set_mtu_6to4'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '11' return inputs def generate_bash_script_singleprivate_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_privatesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_privatesec.sh" service_path = "/etc/systemd/system/robot_privatesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_privatesec.service"]) subprocess.run(["systemctl", "restart", "robot_privatesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singleprivateiransec(inputs): with open("/usr/local/bin/single_privatesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singleprivateiransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_privatesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_privatesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['private_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['change_default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_private_iransec(): inputs = singleprivate_iranuser_inputsec() store_inputs_singleprivateiransec(inputs) generate_bash_script_singleprivate_iransec(inputs) create_script_singleprivateiransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #geneve def robotreconfig_single_geneve(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mPrivate IPversion 4\033[0m") print("2 \033[92mPrivate IPversion 6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robotreconfig_single_geneve4() break elif choice == "2": robotreconfig_single_geneve6() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") def robotreconfig_single_geneve4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve V4 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_geneve4_kharej() break elif choice == "2": robot_single_geneve4_iran() break elif choice == "0": clear() robotreconfig_single_geneve() break else: print("Invalid choice.") def robotreconfig_single_geneve6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve V6 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_geneve6_kharej() break elif choice == "2": robot_single_geneve6_iran() break elif choice == "0": clear() robotreconfig_single_geneve() break else: print("Invalid choice.") #kharej robot reconfig single geneve def singlegeneve4_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '1' inputs['geneve_pointip'] = '1' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '1' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '1' return inputs def generate_bash_script_singlegeneve4_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_geneve.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_geneve.sh" service_path = "/etc/systemd/system/robot_geneve.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_geneve.service"]) subprocess.run(["systemctl", "restart", "robot_geneve.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve4kharej(inputs): with open("/usr/local/bin/single_geneve_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve4kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_geneve.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_geneve_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_pointip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve4_kharej(): inputs = singlegeneve4_kharejuser_input() store_inputs_singlegeneve4kharej(inputs) generate_bash_script_singlegeneve4_kharej(inputs) create_script_singlegeneve4kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve def singlegeneve4_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '1' inputs['geneve_pointip'] = '1' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '2' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '1' return inputs def generate_bash_script_singlegeneve4_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_geneve.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_geneve.sh" service_path = "/etc/systemd/system/robot_geneve.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_geneve.service"]) subprocess.run(["systemctl", "restart", "robot_geneve.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve4iran(inputs): with open("/usr/local/bin/single_geneve_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve4iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_geneve.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_geneve_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_pointip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve4_iran(): inputs = singlegeneve4_iranuser_input() store_inputs_singlegeneve4iran(inputs) generate_bash_script_singlegeneve4_iran(inputs) create_script_singlegeneve4iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") def ipv4_to_ipv6_prefix(ipv4): return "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) #geneve no sec ipv6 def singlegeneve6_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '1' inputs['geneve_pointip'] = '1' inputs['geneve_method'] = '1' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address [Again]: \033[0m") inputs['private_iran_ip'] = ipv4_to_ipv6_prefix(inputs['iran_ip']) inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '1' return inputs def generate_bash_script_singlegeneve6_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_geneve.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_geneve.sh" service_path = "/etc/systemd/system/robot_geneve.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_geneve.service"]) subprocess.run(["systemctl", "restart", "robot_geneve.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve6kharej(inputs): with open("/usr/local/bin/single_geneve_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve6kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_geneve.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_geneve_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_pointip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve6_kharej(): inputs = singlegeneve6_kharejuser_input() store_inputs_singlegeneve6kharej(inputs) generate_bash_script_singlegeneve6_kharej(inputs) create_script_singlegeneve6kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve def singlegeneve6_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '1' inputs['geneve_pointip'] = '1' inputs['geneve_method'] = '2' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address[Again]: \033[0m") inputs['private_kharej_ip'] = ipv4_to_ipv6_prefix(inputs['kharej_ip']) inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '1' return inputs def generate_bash_script_singlegeneve6_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_geneve.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_geneve.sh" service_path = "/etc/systemd/system/robot_geneve.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_geneve.service"]) subprocess.run(["systemctl", "restart", "robot_geneve.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve6iran(inputs): with open("/usr/local/bin/single_geneve_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve6iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_geneve.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_geneve_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_pointip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve6_iran(): inputs = singlegeneve6_iranuser_input() store_inputs_singlegeneve6iran(inputs) generate_bash_script_singlegeneve6_iran(inputs) create_script_singlegeneve6iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #robot geneve ipsec single def robotreconfig_single_genevesec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve + IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mPrivate IPversion 4\033[0m") print("2 \033[92mPrivate IPversion 6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robotreconfig_single_geneve4sec() break elif choice == "2": robotreconfig_single_geneve6sec() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") def robotreconfig_single_geneve4sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve V4 IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_geneve4_kharejsec() break elif choice == "2": robot_single_geneve4_iransec() break elif choice == "0": clear() robotreconfig_single_genevesec() break else: print("Invalid choice.") def robotreconfig_single_geneve6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGeneve V6 IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_geneve6_kharejsec() break elif choice == "2": robot_single_geneve6_iransec() break elif choice == "0": clear() robotreconfig_single_genevesec() break else: print("Invalid choice.") #kharej robot reconfig single geneve def singlegeneve4_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '1' inputs['geneve_address'] = '2' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '80.200.1.2' inputs['geneve_method'] = '1' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '1' return inputs def generate_bash_script_singlegeneve4_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_genevesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_genevesec.sh" service_path = "/etc/systemd/system/robot_genevesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_genevesec.service"]) subprocess.run(["systemctl", "restart", "robot_genevesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve4kharejsec(inputs): with open("/usr/local/bin/single_genevesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve4kharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_genevesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_genevesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_address']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve4_kharejsec(): inputs = singlegeneve4_kharejuser_inputsec() store_inputs_singlegeneve4kharejsec(inputs) generate_bash_script_singlegeneve4_kharejsec(inputs) create_script_singlegeneve4kharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single private def singlegeneve4_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '1' inputs['geneve_address'] = '2' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '80.200.1.2' inputs['geneve_method'] = '2' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '1' return inputs def generate_bash_script_singlegeneve4_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_genevesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_genevesec.sh" service_path = "/etc/systemd/system/robot_genevesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_genevesec.service"]) subprocess.run(["systemctl", "restart", "robot_genevesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve4iransec(inputs): with open("/usr/local/bin/single_genevesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve4iransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_genevesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_genevesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_address']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve4_iransec(): inputs = singlegeneve4_iranuser_inputsec() store_inputs_singlegeneve4iransec(inputs) generate_bash_script_singlegeneve4_iransec(inputs) create_script_singlegeneve4iransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #geneve v6 ipsec def singlegeneve6_kharejuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '1' inputs['geneve_address'] = '2' inputs['private_kharej_ip'] = '2001:db8::1' inputs['private_iran_ip'] = '2001:db8::2' inputs['geneve_method'] = '1' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '1' return inputs def generate_bash_script_singlegeneve6_kharejsec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_genevesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_genevesec.sh" service_path = "/etc/systemd/system/robot_genevesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_genevesec.service"]) subprocess.run(["systemctl", "restart", "robot_genevesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve6kharejsec(inputs): with open("/usr/local/bin/single_genevesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve6kharejsec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_genevesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_genevesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_address']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve6_kharejsec(): inputs = singlegeneve6_kharejuser_inputsec() store_inputs_singlegeneve6kharejsec(inputs) generate_bash_script_singlegeneve6_kharejsec(inputs) create_script_singlegeneve6kharejsec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single private def singlegeneve6_iranuser_inputsec(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '1' inputs['geneve_address'] = '2' inputs['private_kharej_ip'] = '2001:db8::1' inputs['private_iran_ip'] = '2001:db8::2' inputs['geneve_method'] = '2' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '1' return inputs def generate_bash_script_singlegeneve6_iransec(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_genevesec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_genevesec.sh" service_path = "/etc/systemd/system/robot_genevesec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_genevesec.service"]) subprocess.run(["systemctl", "restart", "robot_genevesec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegeneve6iransec(inputs): with open("/usr/local/bin/single_genevesec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegeneve6iransec(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_genevesec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_genevesec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_address']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_geneve6_iransec(): inputs = singlegeneve6_iranuser_inputsec() store_inputs_singlegeneve6iransec(inputs) generate_bash_script_singlegeneve6_iransec(inputs) create_script_singlegeneve6iransec() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") # geneve gre def robotreconfig_single_gengre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mPrivate IPversion 4\033[0m") print("2 \033[92mPrivate IPversion 6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robotreconfig_single_gengre4() break elif choice == "2": robotreconfig_single_gengre6() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") def robotreconfig_single_gengre4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 V4 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gengre4_kharej() break elif choice == "2": robot_single_gengre4_iran() break elif choice == "0": clear() robotreconfig_single_gengre() break else: print("Invalid choice.") def robotreconfig_single_gengre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 V6\033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gengre6_kharej() break elif choice == "2": robot_single_gengre6_iran() break elif choice == "0": clear() robotreconfig_single_gengre() break else: print("Invalid choice.") #kharej robot reconfig single geneve gre 4 def singlegengre4_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '3' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '1' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '4' return inputs def generate_bash_script_singlegengre4_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengre.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengre.sh" service_path = "/etc/systemd/system/robot_gengre.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengre.service"]) subprocess.run(["systemctl", "restart", "robot_gengre.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengre4kharej(inputs): with open("/usr/local/bin/single_gengre_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengre4kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengre.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengre_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengre4_kharej(): inputs = singlegengre4_kharejuser_input() store_inputs_singlegengre4kharej(inputs) generate_bash_script_singlegengre4_kharej(inputs) create_script_singlegengre4kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve gre 4 def singlegengre4_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '3' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '2' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '4' return inputs def generate_bash_script_singlegengre4_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengre.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengre.sh" service_path = "/etc/systemd/system/robot_gengre.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengre.service"]) subprocess.run(["systemctl", "restart", "robot_gengre.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengre4iran(inputs): with open("/usr/local/bin/single_gengre_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengre4iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengre.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengre_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengre4_iran(): inputs = singlegengre4_iranuser_input() store_inputs_singlegengre4iran(inputs) generate_bash_script_singlegengre4_iran(inputs) create_script_singlegengre4iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") # gen gre v6 #kharej robot reconfig single geneve gre 6 def singlegengre6_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '3' inputs['geneve_gremenu'] = '3' inputs['geneve_method'] = '1' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['set_mtu_geneve'] = 'n' inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address[again]: \033[0m") inputs['private_iran_ip'] = ipv4_to_ipv6_prefix(inputs['iran_ip']) inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '4' return inputs def generate_bash_script_singlegengre6_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengre.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengre.sh" service_path = "/etc/systemd/system/robot_gengre.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengre.service"]) subprocess.run(["systemctl", "restart", "robot_gengre.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengre6kharej(inputs): with open("/usr/local/bin/single_gengre_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengre6kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengre.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengre_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengre6_kharej(): inputs = singlegengre6_kharejuser_input() store_inputs_singlegengre6kharej(inputs) generate_bash_script_singlegengre6_kharej(inputs) create_script_singlegengre6kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve gre 6 def singlegengre6_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '3' inputs['geneve_choose'] = '3' inputs['geneve_gremenu'] = '3' inputs['geneve_method'] = '2' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['set_mtu_geneve'] = 'n' inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address[again]: \033[0m") inputs['private_kharej_ip'] = ipv4_to_ipv6_prefix(inputs['kharej_ip']) inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '4' return inputs def generate_bash_script_singlegengre6_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengre.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengre.sh" service_path = "/etc/systemd/system/robot_gengre.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengre.service"]) subprocess.run(["systemctl", "restart", "robot_gengre.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengre6iran(inputs): with open("/usr/local/bin/single_gengre_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengre6iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengre.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengre_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengre6_iran(): inputs = singlegengre6_iranuser_input() store_inputs_singlegengre6iran(inputs) generate_bash_script_singlegengre6_iran(inputs) create_script_singlegengre6iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") # gre gen ipsec def robotreconfig_single_gengresec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 IPSEC \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mPrivate IPversion 4\033[0m") print("2 \033[92mPrivate IPversion 6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robotreconfig_single_gengresec4() break elif choice == "2": robotreconfig_single_gengresec6() break elif choice == "0": clear() robot_single_mnu() break else: print("Invalid choice.") def robotreconfig_single_gengresec4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 IPSEC V4 \033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gengresec4_kharej() break elif choice == "2": robot_single_gengresec4_iran() break elif choice == "0": clear() robotreconfig_single_gengresec() break else: print("Invalid choice.") def robotreconfig_single_gengresec6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mReconfig Robot \033[92mGen GRE6 IPSEC V6\033[93mMenu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mKharej Inputs\033[0m") print("2 \033[92mIRAN Inputs\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": robot_single_gengresec6_kharej() break elif choice == "2": robot_single_gengresec6_iran() break elif choice == "0": clear() robotreconfig_single_gengresec() break else: print("Invalid choice.") #kharej robot reconfig single geneve gresec 4 def singlegengresec4_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '2' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '1' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additioanl_ip'] = input("\033[93mEnter the \033[92mnumber of additional IPs\033[93m for the GRE6 tunnel: \033[0m") inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret Key: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '2' return inputs def generate_bash_script_singlegengresec4_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengresec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengresec.sh" service_path = "/etc/systemd/system/robot_gengresec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengresec.service"]) subprocess.run(["systemctl", "restart", "robot_gengresec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengresec4kharej(inputs): with open("/usr/local/bin/single_gengresec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengresec4kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengresec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengresec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additioanl_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengresec4_kharej(): inputs = singlegengresec4_kharejuser_input() store_inputs_singlegengresec4kharej(inputs) generate_bash_script_singlegengresec4_kharej(inputs) create_script_singlegengresec4kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve gresec 4 def singlegengresec4_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '2' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '66.200.1.1' inputs['private_iran_ip'] = '66.200.2.1' inputs['geneve_method'] = '2' inputs['ip_version'] = '1' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additioanl_ip'] = input("\033[93mEnter the \033[92mnumber of additional IPs\033[93m for the GRE6 tunnel: \033[0m") inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret Key: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '2' return inputs def generate_bash_script_singlegengresec4_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengresec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengresec.sh" service_path = "/etc/systemd/system/robot_gengresec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengresec.service"]) subprocess.run(["systemctl", "restart", "robot_gengresec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengresec4iran(inputs): with open("/usr/local/bin/single_gengresec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengresec4iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengresec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengresec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additioanl_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengresec4_iran(): inputs = singlegengresec4_iranuser_input() store_inputs_singlegengresec4iran(inputs) generate_bash_script_singlegengresec4_iran(inputs) create_script_singlegengresec4iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") # gen gresec v6 #kharej robot reconfig single geneve gre 6 def singlegengresec6_kharejuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '2' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '2001:db8::1' inputs['private_iran_ip'] = '2001:db8::2' inputs['geneve_method'] = '1' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additioanl_ip'] = input("\033[93mEnter the \033[92mnumber of additional IPs\033[93m for the GRE6 tunnel: \033[0m") inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret Key: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '2' return inputs def generate_bash_script_singlegengresec6_kharej(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_iran_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengresec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengresec.sh" service_path = "/etc/systemd/system/robot_gengresec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengresec.service"]) subprocess.run(["systemctl", "restart", "robot_gengresec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengresec6kharej(inputs): with open("/usr/local/bin/single_gengresec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengresec6kharej(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengresec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengresec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additioanl_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengresec6_kharej(): inputs = singlegengresec6_kharejuser_input() store_inputs_singlegengresec6kharej(inputs) generate_bash_script_singlegengresec6_kharej(inputs) create_script_singlegengresec6kharej() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") #iran robot reconfig single geneve gresec 6 def singlegengresec6_iranuser_input(): inputs = {} inputs['input_value'] = '2' inputs['local_tunnel'] = '4' inputs['geneve_choose'] = '2' inputs['geneve_gremenu'] = '3' inputs['private_kharej_ip'] = '2001:db8::1' inputs['private_iran_ip'] = '2001:db8::2' inputs['geneve_method'] = '2' inputs['ip_version'] = '2' print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") inputs['iran_ip'] = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") inputs['kharej_ip'] = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") inputs['set_mtu_6to4'] = 'n' inputs['additioanl_ip'] = input("\033[93mEnter the \033[92mnumber of additional IPs\033[93m for the GRE6 tunnel: \033[0m") inputs['default_route'] = 'n' inputs['set_mtu_gre6'] = 'n' inputs['secret_key'] = input("\033[93mEnter the \033[92mSecret Key: \033[0m") inputs['set_mtu_geneve'] = 'n' inputs['ping_count'] = input("\033[93mEnter the \033[92mping count\033[93m [1-5]:\033[0m ") inputs['ping_interval'] = input("\033[93mEnter the \033[92mping interval\033[93m in seconds:\033[0m ") print("\033[93m╰────────────────────────────────────────────────────────╯\033[0m") inputs['uninstall_input1'] = '2' inputs['uninstall_input2'] = '19' inputs['uninstall_input3'] = '13' inputs['uninstall_input4'] = '6' inputs['uninstall_input5'] = '2' return inputs def generate_bash_script_singlegengresec6_iran(inputs): bash_script = f"""#!/bin/bash while true; do ping -c {inputs['ping_count']} -W {inputs['ping_interval']} {inputs['private_kharej_ip']} if [ $? -ne 0 ]; then echo "Ping failed, running script.." python3 /usr/local/bin/robot_gengresec.py fi sleep {inputs['ping_interval']} done """ script_path = "/usr/local/bin/robot_gengresec.sh" service_path = "/etc/systemd/system/robot_gengresec.service" with open(script_path, "w") as script_file: script_file.write(bash_script) os.chmod(script_path, 0o755) service_content = f"""[Unit] Description=Ping Check Service [Service] ExecStart={script_path} Restart=always [Install] WantedBy=multi-user.target """ with open(service_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "robot_gengresec.service"]) subprocess.run(["systemctl", "restart", "robot_gengresec.service"]) print(f"\033[92mscript saved and service created\033[0m") def store_inputs_singlegengresec6iran(inputs): with open("/usr/local/bin/single_gengresec_inputs.txt", "w") as f: for key, value in inputs.items(): f.write(f"{key}={value}\n") def create_script_singlegengresec6iran(): directory = "/usr/local/bin" script_path = os.path.join(directory, "robot_gengresec.py") lines = [ "import time", "import subprocess", "import os", "", "def read_inputs():", " inputs = {}", " with open('/usr/local/bin/single_gengresec_inputs.txt', 'r') as f:", " for line in f:", " key, value = line.strip().split('=')", " inputs[key] = value", " return inputs", "", "def run_script(inputs):", " subprocess.run(['rm', '-f', 'ubuntu24.py'])", " subprocess.run(['wget', 'https://github.com/Azumi67/6TO4-GRE-IPIP-SIT/releases/download/ubuntu24/ubuntu24.py'])", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['uninstall_input1']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input2']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input3']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['uninstall_input5']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.close()", " process.wait()", "", " process = subprocess.Popen(['python3', 'ubuntu24.py'], stdin=subprocess.PIPE, text=True)", " time.sleep(10)", "", " process.stdin.write(f\"{inputs['input_value']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['local_tunnel']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_choose']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_gremenu']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['geneve_method']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['ip_version']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['iran_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['kharej_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_6to4']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['additioanl_ip']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['default_route']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_gre6']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['secret_key']}\\n\")", " process.stdin.flush()", " time.sleep(7)", "", " process.stdin.write(f\"{inputs['set_mtu_geneve']}\\n\")", " process.stdin.flush()", "", " process.stdin.close()", " process.wait()", "", "def main():", " inputs = read_inputs()", "", " run_script(inputs)", "", "main()" ] with open(script_path, "w") as script_file: script_file.write("\n".join(lines)) print(f"\033[92mScript saved\033[0m") def robot_single_gengresec6_iran(): inputs = singlegengresec6_iranuser_input() store_inputs_singlegengresec6iran(inputs) generate_bash_script_singlegengresec6_iran(inputs) create_script_singlegengresec6iran() print("\033[92mInputs have been saved and the service has been created successfully\033[0m") services = [ ("robot_ip6ip6", [ "/usr/local/bin/robot_ip6ip6.py", "/usr/local/bin/robot_ip6ip6.sh", "/etc/systemd/system/robot_ip6ip6.service", "/usr/local/bin/single_ip6ip6_inputs.txt" ]), ("robot_ip6ip6sec", [ "/usr/local/bin/robot_ip6ip6sec.py", "/usr/local/bin/robot_ip6ip6sec.sh", "/etc/systemd/system/robot_ip6ip6sec.service", "/usr/local/bin/single_ip6ip6sec_inputs.txt" ]), ("robot_gre6", [ "/usr/local/bin/robot_gre6.py", "/usr/local/bin/robot_gre6.sh", "/etc/systemd/system/robot_gre6.service", "/usr/local/bin/single_gre6_inputs.txt" ]), ("robot_gre6sec", [ "/usr/local/bin/robot_gre6sec.py", "/usr/local/bin/robot_gre6sec.sh", "/etc/systemd/system/robot_gre6sec.service", "/usr/local/bin/single_gre6sec_inputs.txt" ]), ("robot_private", [ "/usr/local/bin/robot_private.py", "/usr/local/bin/robot_private.sh", "/etc/systemd/system/robot_private.service", "/usr/local/bin/single_private_inputs.txt" ]), ("robot_privatesec", [ "/usr/local/bin/robot_privatesec.py", "/usr/local/bin/robot_privatesec.sh", "/etc/systemd/system/robot_privatesec.service", "/usr/local/bin/single_privatesec_inputs.txt" ]), ("robot_geneve", [ "/usr/local/bin/robot_geneve.py", "/usr/local/bin/robot_geneve.sh", "/etc/systemd/system/robot_geneve.service", "/usr/local/bin/single_geneve_inputs.txt" ]), ("robot_genevesec", [ "/usr/local/bin/robot_genevesec.py", "/usr/local/bin/robot_genevesec.sh", "/etc/systemd/system/robot_genevesec.service", "/usr/local/bin/single_genevesec_inputs.txt" ]), ("robot_gengre", [ "/usr/local/bin/robot_gengre.py", "/usr/local/bin/robot_gengre.sh", "/etc/systemd/system/robot_gengre.service", "/usr/local/bin/single_gengre_inputs.txt" ]), ("robot_gengresec", [ "/usr/local/bin/robot_gengresec.py", "/usr/local/bin/robot_gengresec.sh", "/etc/systemd/system/robot_gengresec.service", "/usr/local/bin/single_gengresec_inputs.txt" ]), ] def command(command): try: subprocess.run(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except Exception as e: pass def remove_file(file_path): try: os.remove(file_path) except FileNotFoundError: pass except Exception as e: pass def uninstall_service(service_name, files): command(f"systemctl stop {service_name}") command(f"systemctl disable {service_name}") command(f"systemctl daemon-reload") for file in files: remove_file(file) def remove(): for service_name, files in services: uninstall_service(service_name, files) print("\033[92mUninstallation is done.\033[0m") #end of single# ## sit def spn_m2_siti_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_m2_ip6ip64_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "192.168.1.2", "remote", "192.168.1.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 192.168.1.2 remote 192.168.1.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## simple ip4 & native gretap6 def spn_gre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap \033[93m+ \033[96mErspan\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + GRE6tap IPV4 \033[0m") print("2. \033[93mErspan + GRE6tap Native \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_gretap4() break elif server_type == "2": spn_gretapn() break elif server_type == "0": clear() espn_menu() break else: print("Invalid choice.") # native gre spn def spn_gretapn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mERSPAN + \033[96mNative \033[93m+\033[92m Gretap6 \033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_sim_gre6tapk() break elif server_type == "2": spn_sim_gre6tapi() break elif server_type == "3": clear() spn_gre6tap() break else: print("Invalid choice.") def spn_sim_gre6tapk(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ip4_gretapk1() break elif server_type == "2": spn_ip4_gretapk2() break else: print("Invalid choice.") def tap6rn_kharej1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def tap6rn_kharej1(): tap6rn_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 create_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", "2002:831a::2"], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def spn_ip4_gretapk1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") tap6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ip4_gretapk2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") tap6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran def tap6rn_iran1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def tap6rn_iran1(): tap6rn_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def spn_sim_gre6tapi(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ip4_gretapi1() break elif server_type == "2": spn_ip4_gretapi2() break else: print("Invalid choice.") def spn_ip4_gretapi1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") tap6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_ip4_gretapi2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") tap6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # ip4 gre6 erspan def spn_gretap4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mErspan \033[93m+ \033[96mGRE6tap \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gretapk_spn() break elif server_type == "2": gretapi_spn() break elif server_type == "3": clear() spn_gre6tap() break else: print("Invalid choice.") def gretapk_spn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_kh_tap() def spn_kh_tap(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipk_tap1() break elif server_type == "2": spn_ipk_tap2() break else: print("Invalid choice.") def spn_ipk_tap1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ipk_tap2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gretapi_spn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn2_tapir() def spn2_tapir(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_tapipi_1() break elif server_type == "2": spn_tapipi_2() break else: print("Invalid choice.") def spn_tapipi_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_tapipi_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # simple ip4 & native gre6 def spn_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6 \033[93m+ \033[96mErspan\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + GRE6 IPV4 \033[0m") print("2. \033[93mErspan + GRE6 Native \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_gre4() break elif server_type == "2": spn_gren() break elif server_type == "0": clear() espn_menu() break else: print("Invalid choice.") # native gre spn def spn_gren(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mERSPAN + \033[96mNative \033[93m+\033[92m Gre6 \033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_sim_gre6k() break elif server_type == "2": spn_sim_gre6i() break elif server_type == "3": clear() spn_gre6() break else: print("Invalid choice.") def spn_sim_gre6k(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ip4_grek1() break elif server_type == "2": spn_ip4_grek2() break else: print("Invalid choice.") def gree6rn_kharej1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6rn_kharej1(): gree6rn_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def spn_ip4_grek1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gree6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ip4_grek2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gree6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran def gree6rn_iran1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6rn_iran1(): gree6rn_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def spn_sim_gre6i(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ip4_grei1() break elif server_type == "2": spn_ip4_grei2() break else: print("Invalid choice.") def spn_ip4_grei1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gree6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_ip4_grei2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gree6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # ip4 gre6 erspan def spn_gre4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mErspan \033[93m+ \033[96mGRE6 \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_spn_mnu() break elif server_type == "2": iran_spn_mnu() break elif server_type == "3": clear() spn_gre6() break else: print("Invalid choice.") def kharej_spn_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_kh() def spn_kh(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipk_1() break elif server_type == "2": spn_ipk_2() break else: print("Invalid choice.") def spn_ipk_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def spn_ipk_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_spn_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn2_ir() def spn2_ir(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipi_1() break elif server_type == "2": spn_ipi_2() break else: print("Invalid choice.") def spn_ipi_1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def spn_ipi_2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # gre6tap ip4 & ip6 def ipsec_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan + IPsec\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + IPsec \033[0m") print("2. \033[96mGRE6 | Erspan + IPsec \033[0m") print("3. \033[93mGRE6tap | Erspan + IPsec \033[0m") print("4. \033[96mIPsec Reset Timer \033[92m[Optional] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_ipsec_mn() break elif server_type == "2": espn_sec() break elif server_type == "3": espn_gretap() break elif server_type == "4": choose_reset() break elif server_type == "0": clear() espn_menu() break else: print("Invalid choice.") # reset def ipsec_sh(): subprocess.run(["rm", "-f", "/etc/ipsec.sh"]) ipsec_script = """ #!/bin/bash sudo systemctl daemon-reload sudo ipsec stop sudo systemctl restart strongswan-starter sudo systemctl restart strongswan sudo journalctl --vacuum-size=1M --unit=strongswan-starter.service sudo journalctl --vacuum-size=1M --unit=strongswan.service """ with open("/etc/ipsec.sh", "w") as file: file.write(ipsec_script) subprocess.run(["chmod", "+x", "/etc/ipsec.sh"]) def ipsec2_sh(): subprocess.run(["rm", "-f", "/etc/ipsec2.sh"]) ipsec_script = """ #!/bin/bash sudo systemctl daemon-reload sudo ipsec stop sudo systemctl restart strong-azumi1 sudo journalctl --vacuum-size=1M --unit=strong-azumi1.service """ with open("/etc/ipsec2.sh", "w") as file: file.write(ipsec_script) subprocess.run(["chmod", "+x", "/etc/ipsec2.sh"]) # ipsec def vxlan_choose_ipsecmnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan Method:\033[0m") print("1. \033[92mRegular Vxlan + IPSEC\033[0m") print("2. \033[93mVXLAN + Geneve + IPSEC [ Working on it]\033[0m") print("3. \033[96mVxlan + DNS + IPSEC [ Working on it]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlan_menusec1() break elif server_type == "2": vxlan_menusec2() break elif server_type == "3": vxlan_menusec3() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def vxlan_menusec1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mRegular Vxlan IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Regular Vxlan + IPSEC Method:\033[0m") print("1. \033[96mP2P\033[0m") print("2. \033[92mVXLAN Bridge Setup with IP Pointing\033[0m") print("3. \033[93mFDB VXLAN /W Bridge\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlansec_p2p() break elif server_type == "2": vxlan_pointipsec() break elif server_type == "3": vxlan_macipsec() break elif server_type == "0": clear() vxlan_choose_ipsecmnu() break else: print("Invalid choice.") def vxlansec_p2p(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanp2p_ipv4_sec() break elif server_type == "2": vxlanp2p_ipv6_sec() break elif server_type == "0": clear() vxlan_menusec1() break else: print("Invalid choice.") def get_default_interface(): try: output = subprocess.check_output(["ip", "route", "show", "default"]).decode() lines = output.strip().split("\n") for line in lines: if "default via" in line: parts = line.split() interface = parts[4] return interface except subprocess.CalledProcessError: pass return None def has_ipv4_address(interface): addresses = netifaces.ifaddresses(interface) return netifaces.AF_INET in addresses def main_interface(): default_interface = get_default_interface() if default_interface and has_ipv4_address(default_interface): return default_interface return None def vxlan_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "30.0.0.2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def vxlan_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "30.0.0.1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def vxlan_cron_job(): try: subprocess.run( "crontab -l | grep -v '/bin/bash /usr/local/bin/bridge.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /usr/local/bin/bridge.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_vxlan_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_vxlan.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_vxlan_service.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_vxlan_service"]) subprocess.run(["systemctl", "start", "ping_vxlan_service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_vxlan_service"]) def install_vxlan(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling Bridge..\033[0m") install_process = subprocess.Popen( ["sudo", "apt", "install", "bridge-utils", "iproute2", "-y"] ) install_process.wait() print("Bridge Installation complete.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def config_vxlan(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn vxlan1 left=%defaultroute leftsubnet=30.0.0.1/32 leftid=30.0.0.1 right=30.0.0.2 rightsubnet=30.0.0.2/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'30.0.0.2 30.0.0.1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def permissionz1(): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def config_vxlan2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn vxlan1 left=%defaultroute leftsubnet=30.0.0.2/32 leftid=30.0.0.2 right=30.0.0.1 rightsubnet=30.0.0.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'30.0.0.1 30.0.0.2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def vxlan_pingv6_1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db8:0:1::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def vxlan_pingv6_2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db8:0:1::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def configv6_vxlan(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn vxlan1 left=%defaultroute leftsubnet=2001:db8:0:1::1/64 leftid=2001:db8:0:1::1 right=2001:db8:0:1::2 rightsubnet=2001:db8:0:1::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8:0:1::2 2001:db8:0:1::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def configv6_vxlan2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn vxlan1 left=%defaultroute leftsubnet=2001:db8:0:1::2/64 leftid=2001:db8:0:1::2 right=2001:db8:0:1::1 rightsubnet=2001:db8:0:1::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8:0:1::1 2001:db8:0:1::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def vxlanp2p_ipv4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan P2P IPSEC V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejsec_vxlan_v4p2p() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iransec_vxlan_v4p2p() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlansec_p2p() break else: print("Invalid choice.") def kharejsec_vxlan_v4p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P IPSEC \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) config_vxlan(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 30.0.0.1/24 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P /W IPSEC Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iransec_vxlan_v4p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) config_vxlan2(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 30.0.0.2/24 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P /W IPSEC Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanp2p_ipv6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan P2P IPSEC V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejv6sec_vxlan_p2p() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iranv6sec_vxlan_p2p() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlansec_p2p() break else: print("Invalid choice.") def kharejv6sec_vxlan_p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P IPSEC V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) configv6_vxlan(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 2001:db8:0:1::1/64 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P /W IPSEC Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6sec_vxlan_p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P IPSEC V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) configv6_vxlan2(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 2001:db8:0:1::2/64 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P /W IPSEC Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # method2 brige point ip def vxlan_macipsec(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanmac_ipv4_sec() break elif server_type == "2": vxlanmac_ipv6_sec() break elif server_type == "0": clear() vxlan_menusec1() break else: print("Invalid choice.") def vxlanmac_ipv4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Bridge & Mac IPSEC V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejsec_vxlan_v4mac() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iransec_vxlan_v4mac() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlan_macipsec() break else: print("Invalid choice.") def kharejsec_vxlan_v4mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring Vxlan Bridge & Mac IPSEC \033[92mKharej\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() config_vxlan(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 30.0.0.1/24 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iransec_vxlan_v4mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac IPSEC \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() config_vxlan2(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 30.0.0.2/24 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanmac_ipv6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Mac IPSEC V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejv6sec_vxlan_mac() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iranv6sec_vxlan_mac() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlan_macipsec() break else: print("Invalid choice.") def kharejv6sec_vxlan_mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac IPSEC V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() configv6_vxlan(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 2001:db8:0:1::1/64 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6sec_vxlan_mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac IPSEC V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() configv6_vxlan2(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 2001:db8:0:1::2/64 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # method 2 point def vxlan_pointipsec(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanip_ipv4_sec() break elif server_type == "2": vxlanip_ipv6_sec() break elif server_type == "0": clear() vxlan_menusec1() break else: print("Invalid choice.") def vxlanip_ipv4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Bridge & IP IPSEC V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejsec_vxlan_v4ip() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iransec_vxlan_v4ip() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlan_pointipsec() break else: print("Invalid choice.") def kharejsec_vxlan_v4ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring Vxlan Bridge & IP IPSEC \033[92mKharej\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() config_vxlan(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 30.0.0.1/24 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iransec_vxlan_v4ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP IPSEC \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() config_vxlan2(psk) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 30.0.0.2/24 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanip_ipv6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan IP IPSEC V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejv6sec_vxlan_ip() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iranv6sec_vxlan_ip() restart_forced_strongazumi() break elif server_type == "0": os.system("clear") vxlan_pointipsec() break else: print("Invalid choice.") def kharejv6sec_vxlan_ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP IPSEC V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() configv6_vxlan(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 2001:db8:0:1::1/64 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6sec_vxlan_ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP IPSEC V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() configv6_vxlan2(psk) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 2001:db8:0:1::2/64 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # no ipsec def vxlan_choose_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan Method:\033[0m") print("1. \033[92mRegular Vxlan\033[0m") print("2. \033[93mIsatap + Vxlan \033[0m") print("3. \033[96mSit + Vxlan \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlan_menu1() break elif server_type == "2": vxlan_menu2() break elif server_type == "3": vxlan_menu3() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def vxlan_menu1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mRegular Vxlan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Regular Vxlan Method:\033[0m") print("1. \033[96mP2P\033[0m") print("2. \033[92mVXLAN Bridge Setup /W IP Pointing\033[0m") print("3. \033[93mFDB VXLAN /W Bridge\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlan_p2p() break elif server_type == "2": vxlan_pointip() break elif server_type == "3": vxlan_macip() break elif server_type == "0": clear() vxlan_choose_regular() break else: print("Invalid choice.") def vxlan_p2p(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanp2p_ipv4_regular() break elif server_type == "2": vxlanp2p_ipv6_regular() break elif server_type == "0": clear() vxlan_menu1() break else: print("Invalid choice.") def vxlanp2p_ipv4_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan P2P V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_vxlan_v4p2p() break elif server_type == "2": iran_vxlan_v4p2p() break elif server_type == "0": os.system("clear") vxlan_p2p() break else: print("Invalid choice.") def kharej_vxlan_v4p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 30.0.0.1/24 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_vxlan_v4p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) ufw(remote_ip) ufw("30.0.0.2") ufw("30.0.0.1") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 30.0.0.2/24 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanp2p_ipv6_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan P2P V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejv6_vxlan_p2p() break elif server_type == "2": iranv6_vxlan_p2p() break elif server_type == "0": os.system("clear") vxlan_p2p() break else: print("Invalid choice.") def kharejv6_vxlan_p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 2001:db8:0:1::1/64 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6_vxlan_p2p(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan P2P V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN \033[93mIPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "88", "local", local_ip, "remote", remote_ip, "dev", interface, "dstport", dst_port, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 88 local {local_ip} remote {remote_ip} dev {interface} dstport {dst_port}\n" ) f.write("sudo ip addr add 2001:db8:0:1::2/64 dev vxlan\n") f.write("sudo ip link set vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan P2P Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # method2 brige point ip def vxlan_macip(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanmac_ipv4_regular() break elif server_type == "2": vxlanmac_ipv6_regular() break elif server_type == "0": clear() vxlan_menu1() break else: print("Invalid choice.") def vxlanmac_ipv4_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Bridge & Mac V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_vxlan_v4mac() break elif server_type == "2": iran_vxlan_v4mac() break elif server_type == "0": os.system("clear") vxlan_macip() break else: print("Invalid choice.") def kharej_vxlan_v4mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Bridge & Mac \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 30.0.0.1/24 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_vxlan_v4mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("30.0.0.2") ufw("30.0.0.1") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 30.0.0.2/24 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanmac_ipv6_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Mac V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejv6_vxlan_mac() break elif server_type == "2": iranv6_vxlan_mac() break elif server_type == "0": os.system("clear") vxlan_macip() break else: print("Invalid choice.") def kharejv6_vxlan_mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 2001:db8:0:1::1/64 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6_vxlan_mac(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Mac V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "100", "dstport", dst_port, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( [ "sudo", "bridge", "fdb", "append", "to", "00:00:00:00:00:00", "dst", remote_ip, "dev", "vxlan", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "vxlan"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 100 dstport {dst_port} dev {interface} \n" ) f.write( f"sudo bridge fdb append to 00:00:00:00:00:00 dst {remote_ip} dev vxlan\n" ) f.write("sudo ip addr add 2001:db8:0:1::2/64 dev vxlan\n") f.write("sudo ip link set dev vxlan up\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan FDB With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # method 2 point def vxlan_pointip(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Vxlan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlanip_ipv4_regular() break elif server_type == "2": vxlanip_ipv6_regular() break elif server_type == "0": clear() vxlan_menu1() break else: print("Invalid choice.") def vxlanip_ipv4_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Bridge & IP V4 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_vxlan_v4ip() break elif server_type == "2": iran_vxlan_v4ip() break elif server_type == "0": os.system("clear") vxlan_pointip() break else: print("Invalid choice.") def kharej_vxlan_v4ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan Bridge & IP \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.1/24", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 30.0.0.1/24 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_vxlan_v4ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("30.0.0.1") ufw("30.0.0.2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "30.0.0.2/24", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 30.0.0.2/24 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="30.0.0.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 30.0.0.2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # ipv6 def vxlanip_ipv6_regular(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan IP V6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejv6_vxlan_ip() break elif server_type == "2": iranv6_vxlan_ip() break elif server_type == "0": os.system("clear") vxlan_pointip() break else: print("Invalid choice.") def kharejv6_vxlan_ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP V6 \033[92mKharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding Vxlan IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::1/64", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 2001:db8:0:1::1/64 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_1() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mKharej Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranv6_vxlan_ip(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Vxlan IP V6 \033[92mIRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification("\033[93mAdding Vxlan IP addresses for IRAN server...\033[0m") if os.path.isfile("/usr/local/bin/bridge.sh"): os.remove("/usr/local/bin/bridge.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") dst_port = input("\033[93mEnter \033[92mdestination port\033[93m: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufwport(dst_port) install_vxlan() ufw(remote_ip) ufw("2001:db8:0:1::1") ufw("2001:db8:0:1::2") find_interface = input( "\033[93mDo you want meh to find the \033[92mmain interface\033[96m automatically\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if find_interface.lower() == "yes" or find_interface.lower() == "y": interface = main_interface() if interface is None: print("\033[91merror: Couldn't find your network interface.\033[0m") return else: interface = input( "\033[93mWhat is your \033[92mmain interface\033[93m? \033[0m" ) subprocess.run( [ "sudo", "ip", "link", "add", "vxlan", "type", "vxlan", "id", "42", "dstport", dst_port, "remote", remote_ip, "dev", interface, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "add", "azumibr", "type", "bridge"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "vxlan", "master", "azumibr"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "vxlan", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "link", "set", "dev", "azumibr", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8:0:1::2/64", "dev", "azumibr"], stdout=subprocess.DEVNULL, ) with open("/usr/local/bin/bridge.sh", "w") as f: f.write( f"sudo ip link add vxlan type vxlan id 42 dstport {dst_port} remote {remote_ip} dev {interface} \n" ) f.write("sudo ip link add azumibr type bridge\n") f.write("sudo ip link set vxlan master azumibr\n") f.write("sudo ip link set dev vxlan up\n") f.write("sudo ip link set dev azumibr up\n") f.write("sudo ip addr add 2001:db8:0:1::2/64 dev azumibr\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Vxlan & Bridge]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value[Vxlan]\033[93m: \033[0m" ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" mtu_value2 = input( "\033[93mEnter the desired\033[92m MTU value[Bridge]\033[93m: \033[0m" ) mtu_command2 = f"ip link set dev azumibr mtu {mtu_value2}\n" with open("/usr/local/bin/bridge.sh", "a") as f: f.write(mtu_command) f.write(mtu_command2) subprocess.run(mtu_command, shell=True, check=True) subprocess.run(mtu_command2, shell=True, check=True) display_checkmark("\033[92mVxlan ip added successfully!\033[0m") file_path = "/usr/local/bin/bridge.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) vxlan_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") vxlan_pingv6_2() sleep(1) script_content1 = """#!/bin/bash ip_address="2001:db8:0:1::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_vxlan.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_vxlan.sh", 0o755) ping_vxlan_service() display_notification("\033[93mVxlan IP With Bridge Configured\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mIRAN Server \033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2001:db8:0:1::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # uninstall ipsec def vxlan_uninstall(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mRegular Vxlan\033[0m") print("2. \033[92mRegular Vxlan + IPSEC\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_vxlan() break elif server_type == "2": remove_vxlansec() break elif server_type == "0": os.system("clear") remove_menu() break else: print("Invalid choice.") def remote_ip_vx2(): gen_path = "/usr/local/bin/bridge.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "sudo bridge fdb append" in line: parts = line.split() remote_ip = parts[-3] return remote_ip return None def remote_ip_vx(): gen_path = "/usr/local/bin/bridge.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: parts = line.split() remote_index = parts.index("remote") remote_ip = parts[remote_index + 1] remote_ip = remote_ip.strip('"') return remote_ip return None def remove_vxlansec(): os.system("clear") delete_cron1() delete_cron2() remote_ip = remote_ip_vx() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) remote_ip2 = remote_ip_vx2() if remote_ip2 is None: print("Unable to retrieve FDB remote IP") else: delufw(remote_ip2) delufw("30.0.0.1") delufw("30.0.0.2") delufw("2001:db8:0:1::2") delufw("2001:db8:0:1::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mVxlan + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if ( subprocess.call( "test -f /usr/local/bin/bridge.sh > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run("rm /usr/local/bin/bridge.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /usr/local/bin/bridge.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_vxlan.sh", shell=True) subprocess.run( "systemctl disable ping_vxlan_service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_vxlan_service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_vxlan_service.service > /dev/null 2>&1", shell=True, ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev vxlan down > /dev/null", shell=True) subprocess.run("ip link delete vxlan > /dev/null", shell=True) subprocess.run("ip link delete azumibr > /dev/null", shell=True) sleep(1) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_vxlan(): os.system("clear") remote_ip = remote_ip_vx() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) remote_ip2 = remote_ip_vx2() if remote_ip2 is None: print("Unable to retrieve FDB remote IP") else: delufw(remote_ip2) delufw("30.0.0.1") delufw("30.0.0.2") delufw("2001:db8:0:1::2") delufw("2001:db8:0:1::1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mVxlan\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if ( subprocess.call( "test -f /usr/local/bin/bridge.sh > /dev/null 2>&1", shell=True ) == 0 ): subprocess.run("rm /usr/local/bin/bridge.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /usr/local/bin/bridge.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_vxlan.sh", shell=True) subprocess.run( "systemctl disable ping_vxlan_service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_vxlan_service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_vxlan_service.service > /dev/null 2>&1", shell=True, ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev vxlan down > /dev/null", shell=True) subprocess.run("ip link delete vxlan > /dev/null", shell=True) subprocess.run("ip link delete azumibr > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def vxlan_mtu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mVxlan MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mRegular Vxlan\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlan_mtuz() break elif server_type == "0": os.system("clear") mtu_menu() break else: print("Invalid choice.") def vxlan_mtuz(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mRegular Vxlan MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mP2P\033[0m") print("2. \033[93mVXLAN Bridge Setup with IP Pointing\033[0m") print("3. \033[97mFDB\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": vxlan_mtuz1() break elif server_type == "2": vxlan_mtuz2() break elif server_type == "3": vxlan_mtuz2() break elif server_type == "0": os.system("clear") mtu_menu() break else: print("Invalid choice.") def vxlan_mtuz1(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mVxlan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev vxlan mtu {mtu_value}\n" if os.path.exists("/usr/local/bin/bridge.sh"): with open("/usr/local/bin/bridge.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev vxlan mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/usr/local/bin/bridge.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def vxlan_mtuz2(): mtu_value_vxlan = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mVxlan \033[93m]:\033[0m " ) mtu_command_vxlan = f"ip link set dev vxlan mtu {mtu_value_vxlan}\n" mtu_value_bridge = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mBridge \033[93m]:\033[0m " ) mtu_command_bridge = f"ip link set dev azumibr mtu {mtu_value_bridge}\n" if os.path.exists("/usr/local/bin/bridge.sh"): with open("/usr/local/bin/bridge.sh", "r") as file: sh_contents = file.readlines() mtu_vxlan_exists = False mtu_bridge_exists = False for i in range(len(sh_contents)): if "link set dev vxlan mtu" in sh_contents[i]: sh_contents[i] = mtu_command_vxlan mtu_vxlan_exists = True elif "link set dev azumibr mtu" in sh_contents[i]: sh_contents[i] = mtu_command_bridge mtu_bridge_exists = True if not mtu_vxlan_exists: sh_contents.append(mtu_command_vxlan) if not mtu_bridge_exists: sh_contents.append(mtu_command_bridge) with open("/usr/local/bin/bridge.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU commands edited successfully\033[0m") subprocess.run(mtu_command_vxlan, shell=True) subprocess.run(mtu_command_bridge, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def delete_cron1(): entries_to_delete = [ "0 * * * * /bin/bash /etc/ipsec.sh", "0 */2 * * * /bin/bash /etc/ipsec.sh", "0 */3 * * * /bin/bash /etc/ipsec.sh", "0 */4 * * * /bin/bash /etc/ipsec.sh", "0 */5 * * * /bin/bash /etc/ipsec.sh", "0 */6 * * * /bin/bash /etc/ipsec.sh", "0 */7 * * * /bin/bash /etc/ipsec.sh", "0 */8 * * * /bin/bash /etc/ipsec.sh", "0 */9 * * * /bin/bash /etc/ipsec.sh", "0 */10 * * * /bin/bash /etc/ipsec.sh", "0 */11 * * * /bin/bash /etc/ipsec.sh", "0 */12 * * * /bin/bash /etc/ipsec.sh", "0 */13 * * * /bin/bash /etc/ipsec.sh", "0 */14 * * * /bin/bash /etc/ipsec.sh", "0 */15 * * * /bin/bash /etc/ipsec.sh", "0 */16 * * * /bin/bash /etc/ipsec.sh", "0 */17 * * * /bin/bash /etc/ipsec.sh", "0 */18 * * * /bin/bash /etc/ipsec.sh", "0 */19 * * * /bin/bash /etc/ipsec.sh", "0 */20 * * * /bin/bash /etc/ipsec.sh", "0 */21 * * * /bin/bash /etc/ipsec.sh", "0 */22 * * * /bin/bash /etc/ipsec.sh", "0 */23 * * * /bin/bash /etc/ipsec.sh", ] existing_crontab = "" try: existing_crontab = subprocess.check_output("crontab -l", shell=True).decode() except subprocess.CalledProcessError: return new_crontab = existing_crontab for entry in entries_to_delete: if entry in existing_crontab: new_crontab = new_crontab.replace(entry, "") if new_crontab != existing_crontab: subprocess.call(f"echo '{new_crontab}' | crontab -", shell=True) display_notification("\033[92mDeleting Previous Crons..\033[0m") def delete_cron3(): entries_to_delete = [ "0 * * * * /bin/bash /etc/ipsec2.sh", "0 */2 * * * /bin/bash /etc/ipsec2.sh", "0 */3 * * * /bin/bash /etc/ipsec2.sh", "0 */4 * * * /bin/bash /etc/ipsec2.sh", "0 */5 * * * /bin/bash /etc/ipsec2.sh", "0 */6 * * * /bin/bash /etc/ipsec2.sh", "0 */7 * * * /bin/bash /etc/ipsec2.sh", "0 */8 * * * /bin/bash /etc/ipsec2.sh", "0 */9 * * * /bin/bash /etc/ipsec2.sh", "0 */10 * * * /bin/bash /etc/ipsec2.sh", "0 */11 * * * /bin/bash /etc/ipsec2.sh", "0 */12 * * * /bin/bash /etc/ipsec2.sh", "0 */13 * * * /bin/bash /etc/ipsec2.sh", "0 */14 * * * /bin/bash /etc/ipsec2.sh", "0 */15 * * * /bin/bash /etc/ipsec2.sh", "0 */16 * * * /bin/bash /etc/ipsec2.sh", "0 */17 * * * /bin/bash /etc/ipsec2.sh", "0 */18 * * * /bin/bash /etc/ipsec2.sh", "0 */19 * * * /bin/bash /etc/ipsec2.sh", "0 */20 * * * /bin/bash /etc/ipsec2.sh", "0 */21 * * * /bin/bash /etc/ipsec2.sh", "0 */22 * * * /bin/bash /etc/ipsec2.sh", "0 */23 * * * /bin/bash /etc/ipsec2.sh", ] existing_crontab = "" try: existing_crontab = subprocess.check_output("crontab -l", shell=True).decode() except subprocess.CalledProcessError: return new_crontab = existing_crontab for entry in entries_to_delete: if entry in existing_crontab: new_crontab = new_crontab.replace(entry, "") if new_crontab != existing_crontab: subprocess.call(f"echo '{new_crontab}' | crontab -", shell=True) display_notification("\033[92mDeleting Previous Crons..\033[0m") def delete_cron2(): entries_to_delete = [ "*/1 * * * * /bin/bash /etc/ipsec.sh", "*/2 * * * * /bin/bash /etc/ipsec.sh", "*/3 * * * * /bin/bash /etc/ipsec.sh", "*/4 * * * * /bin/bash /etc/ipsec.sh", "*/5 * * * * /bin/bash /etc/ipsec.sh", "*/6 * * * * /bin/bash /etc/ipsec.sh", "*/7 * * * * /bin/bash /etc/ipsec.sh", "*/8 * * * * /bin/bash /etc/ipsec.sh", "*/9 * * * * /bin/bash /etc/ipsec.sh", "*/10 * * * * /bin/bash /etc/ipsec.sh", "*/11 * * * * /bin/bash /etc/ipsec.sh", "*/12 * * * * /bin/bash /etc/ipsec.sh", "*/13 * * * * /bin/bash /etc/ipsec.sh", "*/14 * * * * /bin/bash /etc/ipsec.sh", "*/15 * * * * /bin/bash /etc/ipsec.sh", "*/16 * * * * /bin/bash /etc/ipsec.sh", "*/17 * * * * /bin/bash /etc/ipsec.sh", "*/18 * * * * /bin/bash /etc/ipsec.sh", "*/19 * * * * /bin/bash /etc/ipsec.sh", "*/20 * * * * /bin/bash /etc/ipsec.sh", "*/21 * * * * /bin/bash /etc/ipsec.sh", "*/22 * * * * /bin/bash /etc/ipsec.sh", "*/23 * * * * /bin/bash /etc/ipsec.sh", "*/24 * * * * /bin/bash /etc/ipsec.sh", "*/25 * * * * /bin/bash /etc/ipsec.sh", "*/26 * * * * /bin/bash /etc/ipsec.sh", "*/27 * * * * /bin/bash /etc/ipsec.sh", "*/28 * * * * /bin/bash /etc/ipsec.sh", "*/29 * * * * /bin/bash /etc/ipsec.sh", "*/30 * * * * /bin/bash /etc/ipsec.sh", "*/31 * * * * /bin/bash /etc/ipsec.sh", "*/32 * * * * /bin/bash /etc/ipsec.sh", "*/33 * * * * /bin/bash /etc/ipsec.sh", "*/34 * * * * /bin/bash /etc/ipsec.sh", "*/35 * * * * /bin/bash /etc/ipsec.sh", "*/36 * * * * /bin/bash /etc/ipsec.sh", "*/37 * * * * /bin/bash /etc/ipsec.sh", "*/38 * * * * /bin/bash /etc/ipsec.sh", "*/39 * * * * /bin/bash /etc/ipsec.sh", "*/40 * * * * /bin/bash /etc/ipsec.sh", "*/41 * * * * /bin/bash /etc/ipsec.sh", "*/42 * * * * /bin/bash /etc/ipsec.sh", "*/43 * * * * /bin/bash /etc/ipsec.sh", "*/44 * * * * /bin/bash /etc/ipsec.sh", "*/45 * * * * /bin/bash /etc/ipsec.sh", "*/46 * * * * /bin/bash /etc/ipsec.sh", "*/47 * * * * /bin/bash /etc/ipsec.sh", "*/48 * * * * /bin/bash /etc/ipsec.sh", "*/49 * * * * /bin/bash /etc/ipsec.sh", "*/50 * * * * /bin/bash /etc/ipsec.sh", "*/51 * * * * /bin/bash /etc/ipsec.sh", "*/52 * * * * /bin/bash /etc/ipsec.sh", "*/53 * * * * /bin/bash /etc/ipsec.sh", "*/54 * * * * /bin/bash /etc/ipsec.sh", "*/55 * * * * /bin/bash /etc/ipsec.sh", "*/56 * * * * /bin/bash /etc/ipsec.sh", "*/57 * * * * /bin/bash /etc/ipsec.sh", "*/58 * * * * /bin/bash /etc/ipsec.sh", "*/59 * * * * /bin/bash /etc/ipsec.sh", ] existing_crontab = "" try: existing_crontab = subprocess.check_output("crontab -l", shell=True).decode() except subprocess.CalledProcessError: return new_crontab = existing_crontab for entry in entries_to_delete: if entry in existing_crontab: new_crontab = new_crontab.replace(entry, "") if new_crontab != existing_crontab: subprocess.call(f"echo '{new_crontab}' | crontab -", shell=True) display_notification("\033[92mDeleting Previous Crons..\033[0m") def delete_cron4(): entries_to_delete = [ "*/1 * * * * /bin/bash /etc/ipsec2.sh", "*/2 * * * * /bin/bash /etc/ipsec2.sh", "*/3 * * * * /bin/bash /etc/ipsec2.sh", "*/4 * * * * /bin/bash /etc/ipsec2.sh", "*/5 * * * * /bin/bash /etc/ipsec2.sh", "*/6 * * * * /bin/bash /etc/ipsec2.sh", "*/7 * * * * /bin/bash /etc/ipsec2.sh", "*/8 * * * * /bin/bash /etc/ipsec2.sh", "*/9 * * * * /bin/bash /etc/ipsec2.sh", "*/10 * * * * /bin/bash /etc/ipsec2.sh", "*/11 * * * * /bin/bash /etc/ipsec2.sh", "*/12 * * * * /bin/bash /etc/ipsec2.sh", "*/13 * * * * /bin/bash /etc/ipsec2.sh", "*/14 * * * * /bin/bash /etc/ipsec2.sh", "*/15 * * * * /bin/bash /etc/ipsec2.sh", "*/16 * * * * /bin/bash /etc/ipsec2.sh", "*/17 * * * * /bin/bash /etc/ipsec2.sh", "*/18 * * * * /bin/bash /etc/ipsec2.sh", "*/19 * * * * /bin/bash /etc/ipsec2.sh", "*/20 * * * * /bin/bash /etc/ipsec2.sh", "*/21 * * * * /bin/bash /etc/ipsec2.sh", "*/22 * * * * /bin/bash /etc/ipsec2.sh", "*/23 * * * * /bin/bash /etc/ipsec2.sh", "*/24 * * * * /bin/bash /etc/ipsec2.sh", "*/25 * * * * /bin/bash /etc/ipsec2.sh", "*/26 * * * * /bin/bash /etc/ipsec2.sh", "*/27 * * * * /bin/bash /etc/ipsec2.sh", "*/28 * * * * /bin/bash /etc/ipsec2.sh", "*/29 * * * * /bin/bash /etc/ipsec2.sh", "*/30 * * * * /bin/bash /etc/ipsec2.sh", "*/31 * * * * /bin/bash /etc/ipsec2.sh", "*/32 * * * * /bin/bash /etc/ipsec2.sh", "*/33 * * * * /bin/bash /etc/ipsec2.sh", "*/34 * * * * /bin/bash /etc/ipsec2.sh", "*/35 * * * * /bin/bash /etc/ipsec2.sh", "*/36 * * * * /bin/bash /etc/ipsec2.sh", "*/37 * * * * /bin/bash /etc/ipsec2.sh", "*/38 * * * * /bin/bash /etc/ipsec2.sh", "*/39 * * * * /bin/bash /etc/ipsec2.sh", "*/40 * * * * /bin/bash /etc/ipsec2.sh", "*/41 * * * * /bin/bash /etc/ipsec2.sh", "*/42 * * * * /bin/bash /etc/ipsec2.sh", "*/43 * * * * /bin/bash /etc/ipsec2.sh", "*/44 * * * * /bin/bash /etc/ipsec2.sh", "*/45 * * * * /bin/bash /etc/ipsec2.sh", "*/46 * * * * /bin/bash /etc/ipsec2.sh", "*/47 * * * * /bin/bash /etc/ipsec2.sh", "*/48 * * * * /bin/bash /etc/ipsec2.sh", "*/49 * * * * /bin/bash /etc/ipsec2.sh", "*/50 * * * * /bin/bash /etc/ipsec2.sh", "*/51 * * * * /bin/bash /etc/ipsec2.sh", "*/52 * * * * /bin/bash /etc/ipsec2.sh", "*/53 * * * * /bin/bash /etc/ipsec2.sh", "*/54 * * * * /bin/bash /etc/ipsec2.sh", "*/55 * * * * /bin/bash /etc/ipsec2.sh", "*/56 * * * * /bin/bash /etc/ipsec2.sh", "*/57 * * * * /bin/bash /etc/ipsec2.sh", "*/58 * * * * /bin/bash /etc/ipsec2.sh", "*/59 * * * * /bin/bash /etc/ipsec2.sh", ] existing_crontab = "" try: existing_crontab = subprocess.check_output("crontab -l", shell=True).decode() except subprocess.CalledProcessError: return new_crontab = existing_crontab for entry in entries_to_delete: if entry in existing_crontab: new_crontab = new_crontab.replace(entry, "") if new_crontab != existing_crontab: subprocess.call(f"echo '{new_crontab}' | crontab -", shell=True) display_notification("\033[92mDeleting Previous Crons..\033[0m") def reset_hour(): delete_cron1() delete_cron2() hours = int( input("\033[93mEnter the \033[92mReset Timer\033[93m [in hours]:\033[0m ") ) if hours == 1: cron_entry = "0 * * * * /bin/bash /etc/ipsec.sh" else: cron_entry = f"0 */{hours} * * * /bin/bash /etc/ipsec.sh" try: process = subprocess.run( "crontab -l", shell=True, capture_output=True, text=True ) existing_crontab = process.stdout if existing_crontab.strip() != "": new_crontab = f"{existing_crontab.rstrip()}\n{cron_entry}" else: new_crontab = cron_entry new_crontab += "\n" process = subprocess.run( "crontab -", shell=True, input=new_crontab, text=True, capture_output=True ) if process.returncode == 0: print("\033[92mCron entry added successfully!\033[0m") else: print(f"Failed to add cron entry. Error: {process.stderr}") except Exception as e: print(f"Error: {e}") def reset2_hour(): delete_cron3() delete_cron4() hours = int( input("\033[93mEnter the \033[92mReset Timer\033[93m [in hours]:\033[0m ") ) if hours == 1: cron_entry = "0 * * * * /bin/bash /etc/ipsec2.sh" else: cron_entry = f"0 */{hours} * * * /bin/bash /etc/ipsec2.sh" try: process = subprocess.run( "crontab -l", shell=True, capture_output=True, text=True ) existing_crontab = process.stdout if existing_crontab.strip() != "": new_crontab = f"{existing_crontab.rstrip()}\n{cron_entry}" else: new_crontab = cron_entry new_crontab += "\n" process = subprocess.run( "crontab -", shell=True, input=new_crontab, text=True, capture_output=True ) if process.returncode == 0: print("\033[92mCron entry added successfully!\033[0m") else: print(f"Failed to add cron entry. Error: {process.stderr}") except Exception as e: print(f"Error: {e}") def reset_minutes(): delete_cron1() delete_cron2() minutes = int( input("\033[93mEnter the \033[92mReset Timer\033[93m [in minutes]:\033[0m ") ) cron_entry = f"*/{minutes} * * * * /bin/bash /etc/ipsec.sh" try: process = subprocess.run( "crontab -l", shell=True, capture_output=True, text=True ) existing_crontab = process.stdout if existing_crontab.strip() != "": new_crontab = f"{existing_crontab.rstrip()}\n{cron_entry}" else: new_crontab = cron_entry new_crontab += "\n" process = subprocess.run( "crontab -", shell=True, input=new_crontab, text=True, capture_output=True ) if process.returncode == 0: print("\033[92mCron entry added successfully!\033[0m") else: print(f"Failed to add cron entry. Error: {process.stderr}") except Exception as e: print(f"Error: {e}") def reset2_minutes(): delete_cron3() delete_cron4() minutes = int( input("\033[93mEnter the \033[92mReset Timer\033[93m [in minutes]:\033[0m ") ) cron_entry = f"*/{minutes} * * * * /bin/bash /etc/ipsec2.sh" try: process = subprocess.run( "crontab -l", shell=True, capture_output=True, text=True ) existing_crontab = process.stdout if existing_crontab.strip() != "": new_crontab = f"{existing_crontab.rstrip()}\n{cron_entry}" else: new_crontab = cron_entry new_crontab += "\n" process = subprocess.run( "crontab -", shell=True, input=new_crontab, text=True, capture_output=True ) if process.returncode == 0: print("\033[92mCron entry added successfully!\033[0m") else: print(f"Failed to add cron entry. Error: {process.stderr}") except Exception as e: print(f"Error: {e}") def enable_reset_ipsec(): ipsec_service_remove() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mIPSEC \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_ipsec(interval_seconds) print("\033[93m────────────────────────────────────────\033[0m") def reset_ipsec(interval): service_name = "ipsecreset.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipsec.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipsec_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipsec_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipsec_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash systemctl daemon-reload sudo ipsec stop systemctl restart strong-azumi1 systemctl restart strongswan-starter systemctl restart strongswan sudo journalctl --vacuum-size=1M --unit=strongswan.service sudo journalctl --vacuum-size=1M --unit=strongswan-starter.service """ with open("/etc/reset_ipsec.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipsec.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_ipsec_single(interval): service_name = "ipsecreset.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_ipsec.sh sleep $INTERVAL done """ with open("/usr/local/bin/ipsec_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/ipsec_daemon.sh"]) service_content = f"""[Unit] Description=Custom Daemon [Service] ExecStart=/usr/local/bin/ipsec_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash systemctl daemon-reload sudo ipsec stop systemctl restart strongswan-starter systemctl restart strongswan sudo journalctl --vacuum-size=1M --unit=strongswan.service sudo journalctl --vacuum-size=1M --unit=strongswan-starter.service """ with open("/etc/reset_ipsec.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_ipsec.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset2_minutes_forced(): delete_cron3() delete_cron4() ipsec2_sh() cron_entry = f"*/2 * * * * /bin/bash /etc/ipsec2.sh" try: process = subprocess.run( "crontab -l", shell=True, capture_output=True, text=True ) existing_crontab = process.stdout if existing_crontab.strip() != "": new_crontab = f"{existing_crontab.rstrip()}\n{cron_entry}" else: new_crontab = cron_entry new_crontab += "\n" process = subprocess.run( "crontab -", shell=True, input=new_crontab, text=True, capture_output=True ) if process.returncode == 0: print("\033[92mCron entry added successfully!\033[0m") else: print(f"Failed to add cron entry. Error: {process.stderr}") except Exception as e: print(f"Error: {e}") def choose_reset(): ipsec_service_remove() delete_cron1() delete_cron1() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mIPSEC \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_ipsec_single(interval_seconds) print("\033[93m────────────────────────────────────────\033[0m") def ipsec_service_remove(): try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving stuff...\033[0m") commands = [ "rm /etc/ipsec2.sh", "systemctl disable ipsecreset.service", "systemctl stop ipsecreset.service", "sudo rm /etc/systemd/system/ipsecreset.service", "sudo rm /etc/reset_ipsec.sh" "sudo rm /usr/local/bin/ipsec_daemon.sh", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def choose_reset2(): ipsec_service_remove() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mIPSEC \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_ipsec(interval_seconds) print("\033[93m────────────────────────────────────────\033[0m") ## simpe ip4 def ip4_spn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[93m+ IPV4 \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_spnkh() break elif server_type == "2": simple_spnir() break elif server_type == "3": clear() espn_menu() break else: print("Invalid choice.") def simple_spnkh(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_sim_kharej() def spn_sim_kharej(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip4_simpk1() break elif server_type == "2": ip4_simk2() break else: print("Invalid choice.") def ip4_simpk1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def ip4_simk2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def simple_spnir(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_sim_iran() def spn_sim_iran(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip4_simpi1() break elif server_type == "2": ip4_simpi2() break else: print("Invalid choice.") def ip4_simpi1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ip4_simpi2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## simple ip6 def ip6_spn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[93m+ Native \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_ip6_n() break elif server_type == "2": simple_ip6i_n() break elif server_type == "3": clear() espn_menu() break else: print("Invalid choice.") def simple_ip6_n(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6_simple1_n() def ip6_simple1_n(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip6_simk1_n() break elif server_type == "2": ip6_simk2_n() break else: print("Invalid choice.") def ip6_simk1_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def ip6_simk2_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def simple_ip6i_n(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip6_simple2_n() def ip6_simple2_n(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip6_simpi1_n() break elif server_type == "2": ip6_simpi2_n() break else: print("Invalid choice.") def ip6_simpi1_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ip6_simpi2_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## simple ipsec def simple_ipsec_mn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[93m+ \033[92mIPsec Menu \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNative + Erspan\033[0m") print("2. \033[93mIPV4 + Erspan\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_ipsec_n() break elif server_type == "2": simple_ipsec() break elif server_type == "3": clear() ipsec_mnu() break else: print("Invalid choice.") def simple_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[93m+ IPV4 + \033[92mIPsec \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_ipseck() break elif server_type == "2": simple_ipseci() break elif server_type == "3": clear() simple_ipsec_mn() break else: print("Invalid choice.") def simple_ipseck(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_simple1() def espan_simple1(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_simpk1() break elif server_type == "2": espan_simpk2() break else: print("Invalid choice.") def config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def espan_simpk1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan_simpk2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def simple_ipseci(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_simple2() def espan_simple2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_simpi1() break elif server_type == "2": espan_simpi2() break else: print("Invalid choice.") def espan_simpi1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan_simpi2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # native erspan def simple_ipsec_n(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan \033[93m+ Native + \033[92mIPsec \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simple_ipseck_n() break elif server_type == "2": simple_ipseci_n() break elif server_type == "3": clear() simple_ipsec_mn() break else: print("Invalid choice.") def simple_ipseck_n(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_simple1_n() def espan_simple1_n(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_simk1_n() break elif server_type == "2": espan_simk2_n() break else: print("Invalid choice.") def config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def espan_simk1_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan_simk2_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def simple_ipseci_n(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_simple2_n() def espan_simple2_n(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_simpi1_n() break elif server_type == "2": espan_simpi2_n() break else: print("Invalid choice.") def espan_simpi1_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan_simpi2_n(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", local_ip, "remote", remote_ip, "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local {local_ip} remote {remote_ip} seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## gre6tap erspan def gre6tap_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharej(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def gre6tap_kharejsec(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def kharej_gretap6_menu(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejsec() # sec sleep(1) def gretap6_iran(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gretap6_iransec(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gretap6_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gretap6_menu(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() gretap6_iransec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def espn_gretap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGRE6tap \033[93m+ \033[96mErspan\033[93m + \033[91mIPsec\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + GRE6tap | IPsec + IPV4 \033[0m") print("2. \033[93mErspan + GRE6tap | IPsec + Native \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espn_gretap_ipsec() break elif server_type == "2": espn_gretap_ipsec2() break elif server_type == "0": clear() ipsec_mnu() break else: print("Invalid choice.") def espn_gretap_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mErspan \033[93m+ \033[96mGre6tap \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_gretap_espn() break elif server_type == "2": iran_gretap_espn() break elif server_type == "3": clear() espn_gretap() break else: print("Invalid choice.") def kharej_gretap_espn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_ipgre1() def espan_ipgre1(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipk_gre1() break elif server_type == "2": espan_ipk_gre2() break else: print("Invalid choice.") def espan_ipk_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan_ipk_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharej_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_gretap_espn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_ipgre2() def espan_ipgre2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipi_gre1() break elif server_type == "2": espan_ipi_gre2() break else: print("Invalid choice.") def espan_ipi_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan_ipi_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iran_gretap6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## gre6tap native def espn_gretap_ipsec2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mErspan \033[93m+ \033[96mGre6tap \033[93m+ \033[92mNative \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejna_gretap_espn() break elif server_type == "2": iranna_gretap_espn() break elif server_type == "3": clear() espn_gretap() break else: print("Invalid choice.") def kharejna_gretap_espn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_ipgrena1() def espan_ipgrena1(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipk_grena1() break elif server_type == "2": espan_ipk_grena2() break else: print("Invalid choice.") # kharej prequisite def gre6tapna_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tapna_kharej(): global local_ip, remote_ip gre6tapna_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def espan_ipk_grena1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gre6tapna_kharej() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan_ipk_grena2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gre6tapna_kharej() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## iran prequisite def gretap6na_iran(): global local_ip, remote_ip gretap6na_iran_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gretap6na_iran_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link add name azumig6 type ip6gretap local {local_ip} remote {remote_ip}' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iranna_gretap_espn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_ipgrena2() def espan_ipgrena2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipi_grena1() break elif server_type == "2": espan_ipi_grena2() break else: print("Invalid choice.") def espan_ipi_grena1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gretap6na_iran() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan_ipi_grena2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gretap6na_iran() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## gre6 erspan def espn_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGRE6 \033[93m+ \033[96mErspan\033[93m + \033[91mIPsec\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + GRE6 | IPsec + IPV4 \033[0m") print("2. \033[93mErspan + GRE6 | IPsec + Native \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espn_ipsec() break elif server_type == "2": spn_ip() break elif server_type == "0": clear() ipsec_mnu() break else: print("Invalid choice.") # native gre spn def spn_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mERSPAN + \033[96mNative \033[93m+\033[92m Gre6 \033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn_ipger() break elif server_type == "2": spn_ipgeri() break elif server_type == "3": clear() espn_sec() break else: print("Invalid choice.") def spn_ipger(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan2_ipk_ngre1() break elif server_type == "2": espan2_ipk_ngre2() break else: print("Invalid choice.") def gree6rn_kharej1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6rn_kharej1(): gree6rn_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def config_strongswank_gren(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswank_gren4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswani_gren(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswani_gren4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def espan2_ipk_ngre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gree6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gren4(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan2_ipk_ngre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") gree6rn_kharej1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gren(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # iran def gree6rn_iran1_tunnel(): global local_ip, remote_ip file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6rn_iran1(): gree6rn_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def spn_ipgeri(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan2_ipi_ngre1() break elif server_type == "2": espan2_ipi_ngre2() break else: print("Invalid choice.") def espan2_ipi_ngre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gree6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gren4(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan2_ipi_ngre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") gree6rn_iran1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gren(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan4_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "2001:db8::1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def espan3_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "2001:db8::2"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def espan_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "66.200.2.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def espan2_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "66.200.1.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def ping_gengre_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_espan.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_espan.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_espan.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_espan.service"]) def espan_job(): file_path = "/etc/spn.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def permissionz(num_servers): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec{i}.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def permissions(): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def permissions1(): print("Setting permissions for config files...") subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "chmod", "600", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Setting permissions was successful.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") def install_strongswan(): subprocess.run(["sudo", "apt", "install", "strongswan", "-y"]) print("IPSEC Installation complete.") def config_strongswan(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswank_gre62(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswank_gre6(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswani_gre6(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongswani_gre62(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def espn_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mErspan \033[93m+ \033[96mGRE6 \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_espn_menu() break elif server_type == "2": iran_espn_menu() break elif server_type == "3": clear() ipsec_mnu() break else: print("Invalid choice.") def kharej_espn_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan_ipvers() def espan_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipk_version1() break elif server_type == "2": espan_ipk_version2() break else: print("Invalid choice.") def espan_ipk_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def espan_ipk_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswank_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::1", "remote", "2002:831a::2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::1 remote 2002:831a::2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_espn_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") espan2_ipvers() def espan2_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espan_ipi_version1() break elif server_type == "2": espan_ipi_version2() break else: print("Invalid choice.") def espan_ipi_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre62(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def espan_ipi_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongswani_gre6(psk) subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "ip6erspan", "local", "2002:831a::2", "remote", "2002:831a::1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type ip6erspan local 2002:831a::2 remote 2002:831a::1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumiespn\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def genz_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP \033[0m") print( "2. \033[93mGeneve UDP \033[93m+ \033[92mNative \033[93m| \033[92mTunnelbroker \033[0m" ) print("3. \033[96mGeneve UDP + GRE6 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_ip() break elif server_type == "2": gen2_ip() break elif server_type == "3": genf_ip() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def gen_icmp_install(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGen + ICMP\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_ipicmp() break elif server_type == "2": gen_ipicmpi() break elif server_type == "0": clear() genz_ip() break else: print("Invalid choice.") def remove2_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Multiple Servers Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mUninstall IP6IP6\033[0m") print("2. \033[96mUninstall IP6IP6 + IPSec\033[0m") print("3. \033[93mUninstall 6to4\033[0m") print("4. \033[96mUninstall 6to4 + IPsec\033[0m") print("5. \033[93mUninstall anycast\033[0m") print("6. \033[92mUninstall Gre6\033[0m") print("7. \033[96mUninstall Gre6 + IPSec\033[0m") print("8. \033[93mUninstall Gre6tap\033[0m") print("9. \033[92mUninstall Geneve \033[93m[IPSec included]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": rmv_ipip6() break elif server_type == "2": rmv_ipip6sec() break elif server_type == "3": rmv_private() break elif server_type == "4": rmv_private_sec() break elif server_type == "5": remove_6to41() break elif server_type == "6": rmv_gre6() break elif server_type == "7": rmv_gre6_ipsec() break elif server_type == "8": rmv_gre6tap() break elif server_type == "9": rmv_gen_multi() break elif server_type == "0": clear() main_menu() break else: print("Invalid choice.") # ip6ip6 + IPsec remove menu def rmv_ipip6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPSec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[5] | IRAN[1] + \033[96mIPSEC\033[0m") print("2. \033[93mKharej[1] | IRAN[5] + \033[96mIPSEC\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_ipiptap6_sec() break elif server_type == "2": ir_ipiptap6_sec() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_ipiptap6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPSec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1] + IPsec\033[0m") print("2. \033[93mKharej[2] + IPsec\033[0m") print("3. \033[92mKharej[3] + IPsec\033[0m") print("4. \033[93mKharej[4] + IPsec\033[0m") print("5. \033[92mKharej[5] + IPsec\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN + IPsec \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61_sec() break elif server_type == "2": remove_ipip62_sec() break elif server_type == "3": remove_ipip63_sec() break elif server_type == "4": remove_ipip64_sec() break elif server_type == "5": remove_ipip65_sec() break elif server_type == "6": rmv3_ipiptap_sec() break elif server_type == "0": clear() rmv_ipip6sec() break else: print("Invalid choice.") def rmv3_ipiptap_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_ipip6{}_sec".format(i) globals()[menu_name]() def ir_ipiptap6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1] + IPsec\033[0m") print("2. \033[93mIRAN[2] + IPsec\033[0m") print("3. \033[92mIRAN[3] + IPsec\033[0m") print("4. \033[93mIRAN[4] + IPsec\033[0m") print("5. \033[92mIRAN[5] + IPsec\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej + IPsec \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61_sec() break elif server_type == "2": remove_ipip62_sec() break elif server_type == "3": remove_ipip63_sec() break elif server_type == "4": remove_ipip64_sec() break elif server_type == "5": remove_ipip65_sec() break elif server_type == "6": rmv4_ipiptap_sec() break elif server_type == "0": clear() rmv_ipip6sec() break else: print("Invalid choice.") def rmv4_ipiptap_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_ipip6{}_sec".format(i) globals()[menu_name]() def remove_ipip61_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mIPIP6 + IPSec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip1.sh", shell=True) == 0: subprocess.run("rm /etc/ipip1.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip1.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip62_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mIPIP6 + IPSec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip2.sh", shell=True) == 0: subprocess.run("rm /etc/ipip2.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip2.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip63_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mIPIP6 + IPSec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip3.sh", shell=True) == 0: subprocess.run("rm /etc/ipip3.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip3.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip3 > /dev/null", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip64_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mIPIP6 + IPSec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip4.sh", shell=True) == 0: subprocess.run("rm /etc/ipip4.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip4.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip4 > /dev/null", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip65_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mIPIP6 + IPSec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip5.sh", shell=True) == 0: subprocess.run("rm /etc/ipip5.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip5.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def rmv_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [10]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_ipip6() break elif server_type == "2": ir_ipip6() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "11": rmv1_q() break elif server_type == "0": clear() rmv_ipip6() break else: print("Invalid choice.") def rmv1_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_ipip6{}".format(i) globals()[menu_name]() def ir_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 [10]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "11": rmv2_q() break elif server_type == "0": clear() rmv_ipip6() break else: print("Invalid choice.") def rmv2_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_ipip6{}".format(i) globals()[menu_name]() def remove_ipip61(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip1.sh", shell=True) == 0: subprocess.run("rm /etc/ipip1.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip1.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip62(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip2.sh", shell=True) == 0: subprocess.run("rm /etc/ipip2.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip2.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip63(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip3.sh", shell=True) == 0: subprocess.run("rm /etc/ipip3.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip3.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip3 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip64(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip4.sh", shell=True) == 0: subprocess.run("rm /etc/ipip4.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip4.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip4 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip65(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip5.sh", shell=True) == 0: subprocess.run("rm /etc/ipip5.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip5.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip66(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip6.sh", shell=True) == 0: subprocess.run("rm /etc/ipip6.sh", shell=True) if subprocess.call("test -f /etc/private6.sh", shell=True) == 0: subprocess.run("rm /etc/private6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip6.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v66.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip6.sh", shell=True) subprocess.run( "systemctl disable ping_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v66.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip6.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip6.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip6 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip67(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip7.sh", shell=True) == 0: subprocess.run("rm /etc/ipip7.sh", shell=True) if subprocess.call("test -f /etc/private7.sh", shell=True) == 0: subprocess.run("rm /etc/private7.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip7.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private7.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v67.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip7.sh", shell=True) subprocess.run( "systemctl disable ping_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v67.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip7.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip7.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip7.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip7 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip7 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi7 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip68(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip8.sh", shell=True) == 0: subprocess.run("rm /etc/ipip8.sh", shell=True) if subprocess.call("test -f /etc/private8.sh", shell=True) == 0: subprocess.run("rm /etc/private8.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip8.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private8.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v68.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip8.sh", shell=True) subprocess.run( "systemctl disable ping_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v68.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip8.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip8.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip8.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip8 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip8 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi8 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip69(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip9.sh", shell=True) == 0: subprocess.run("rm /etc/ipip9.sh", shell=True) if subprocess.call("test -f /etc/private9.sh", shell=True) == 0: subprocess.run("rm /etc/private9.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip9.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private9.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v69.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip9.sh", shell=True) subprocess.run( "systemctl disable ping_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v69.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip9.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip9.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip9.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip9 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_ipip610(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip10.sh", shell=True) == 0: subprocess.run("rm /etc/ipip10.sh", shell=True) if subprocess.call("test -f /etc/private10.sh", shell=True) == 0: subprocess.run("rm /etc/private10.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip10.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private10.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v610.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip10.sh", shell=True) subprocess.run( "systemctl disable ping_v610.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v610.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v610.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run( "systemctl disable ping_ip10.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip10.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip10.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip10 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip10 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi10 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # gretap def rmv_gre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6tap\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[10] | IRAN[1]\033[0m") print("2. \033[93mKharej[1] | IRAN[5]\033[0m") print("3. \033[92mKharej[5] | IRAN[1] + \033[96mIPSEC\033[0m") print("4. \033[93mKharej[1] | IRAN[5] + \033[96mIPSEC\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_gretap6() break elif server_type == "2": ir_gretap6() break elif server_type == "3": kh_gretap6_sec() break elif server_type == "4": ir_gretap6_sec() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_gretap6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6tap [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[93mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[93mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": remove_gretap66() break elif server_type == "7": remove_gretap67() break elif server_type == "8": remove_gretap68() break elif server_type == "9": remove_gretap69() break elif server_type == "10": remove_gretap610() break elif server_type == "11": rmv3_qtap() break elif server_type == "0": clear() rmv_gre6tap() break else: print("Invalid choice.") def rmv3_qtap(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gretap6{}".format(i) globals()[menu_name]() def ir_gretap6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6tap [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[93mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[93mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": rmv4_qtap() break elif server_type == "0": clear() rmv_gre6tap() break else: print("Invalid choice.") def rmv4_qtap(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gretap6{}".format(i) globals()[menu_name]() def kh_gretap6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6tap + IPSec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1] + IPsec\033[0m") print("2. \033[93mKharej[2] + IPsec\033[0m") print("3. \033[92mKharej[3] + IPsec\033[0m") print("4. \033[93mKharej[4] + IPsec\033[0m") print("5. \033[92mKharej[5] + IPsec\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN + IPsec \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": rmv3_qtap_sec() break elif server_type == "0": clear() rmv_gre6tap() break else: print("Invalid choice.") def rmv3_qtap_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gretap6{}_sec".format(i) globals()[menu_name]() def ir_gretap6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6tap + IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1] + IPsec\033[0m") print("2. \033[93mIRAN[2] + IPsec\033[0m") print("3. \033[92mIRAN[3] + IPsec\033[0m") print("4. \033[93mIRAN[4] + IPsec\033[0m") print("5. \033[92mIRAN[5] + IPsec\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej + IPsec \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": rmv4_qtap_sec() break elif server_type == "0": clear() rmv_gre6tap() break else: print("Invalid choice.") def rmv4_qtap_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gretap6{}_sec".format(i) globals()[menu_name]() def remove_gretap61(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre61.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip link delete azumig61 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap62(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre62.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip link delete azumig62 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap63(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre63.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip link delete azumig63 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap64(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre64.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip link delete azumig64 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap65(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre65.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip link delete azumig65 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap66(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre66.sh", shell=True) == 0: subprocess.run("rm /etc/gre66.sh", shell=True) if subprocess.call("test -f /etc/private6.sh", shell=True) == 0: subprocess.run("rm /etc/private6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre66.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v66.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip6.sh", shell=True) subprocess.run( "systemctl disable ping_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip6.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip6.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig66 down > /dev/null", shell=True) subprocess.run("ip link delete azumig66 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap67(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre67.sh", shell=True) == 0: subprocess.run("rm /etc/gre67.sh", shell=True) if subprocess.call("test -f /etc/private7.sh", shell=True) == 0: subprocess.run("rm /etc/private7.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre67.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private7.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v67.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip7.sh", shell=True) subprocess.run( "systemctl disable ping_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip7.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip7.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip7.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi7 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi7 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig67 down > /dev/null", shell=True) subprocess.run("ip link delete azumig67 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap68(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre68.sh", shell=True) == 0: subprocess.run("rm /etc/gre68.sh", shell=True) if subprocess.call("test -f /etc/private8.sh", shell=True) == 0: subprocess.run("rm /etc/private8.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre68.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private8.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v68.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip8.sh", shell=True) subprocess.run( "systemctl disable ping_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip8.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip8.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip8.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi8 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi8 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig68 down > /dev/null", shell=True) subprocess.run("ip link delete azumig68 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap69(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre69.sh", shell=True) == 0: subprocess.run("rm /etc/gre69.sh", shell=True) if subprocess.call("test -f /etc/private9.sh", shell=True) == 0: subprocess.run("rm /etc/private9.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre69.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private9.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v69.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip9.sh", shell=True) subprocess.run( "systemctl disable ping_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip9.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip9.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip9.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi9 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig69 down > /dev/null", shell=True) subprocess.run("ip link delete azumig69 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap610(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6tap\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre610.sh", shell=True) == 0: subprocess.run("rm /etc/gre610.sh", shell=True) if subprocess.call("test -f /etc/private10.sh", shell=True) == 0: subprocess.run("rm /etc/private10.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre610.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private10.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v610.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip10.sh", shell=True) subprocess.run( "systemctl disable ping_v610.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v610.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip10.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip10.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip10.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi10 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi10 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig610 down > /dev/null", shell=True) subprocess.run("ip link delete azumig610 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap61_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6tap | IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre61.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip link delete azumig61 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap62_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6tap | IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre62.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip2.sh > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip link delete azumig62 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap63_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6tap | IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre63.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip3.sh > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip link delete azumig63 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap64_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6tap | IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre64.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip4.sh > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip link delete azumig64 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gretap65_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6tap | IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre65.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) subprocess.run("sudo rm /etc/ping_ip5.sh > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip link delete azumig65 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def rmv_gre6_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 + IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[5] | IRAN[1]\033[0m") print("2. \033[93mKharej[1] | IRAN[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_gre6_ipsec() break elif server_type == "2": ir_gre6_ipsec() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_gre6_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 + IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[93mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() break elif server_type == "2": remove_gre62_ipsec() break elif server_type == "3": remove_gre63_ipsec() break elif server_type == "4": remove_gre64_ipsec() break elif server_type == "5": remove_gre65_ipsec() break elif server_type == "6": rmv3_qgre_sec() break elif server_type == "0": clear() rmv_gre6_ipsec() break else: print("Invalid choice.") def rmv3_qgre_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gre6{}_ipsec".format(i) globals()[menu_name]() def ir_gre6_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 + IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[93mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[93mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() break elif server_type == "2": remove_gre62_ipsec() break elif server_type == "3": remove_gre63_ipsec() break elif server_type == "4": remove_gre64_ipsec() break elif server_type == "5": remove_gre65_ipsec() break elif server_type == "6": rmv4_qgre_sec() break elif server_type == "0": clear() rmv_gre6_ipsec() break else: print("Invalid choice.") def rmv4_qgre_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gre6{}_ipsec".format(i) globals()[menu_name]() def remove_gre61_ipsec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6 + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre61.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig61 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre62_ipsec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6 + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre62.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig62 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre63_ipsec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6 + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre63.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig63 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre64_ipsec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6 + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre64.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig64 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre65_ipsec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving \033[92mGRE6 + IPsec\033[93m Tunnel...\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre65.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig65 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def rmv_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[10] | IRAN[1]\033[0m") print("2. \033[93mKharej[1] | IRAN[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_gre6() break elif server_type == "2": ir_gre6() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[93mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[93mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "6": remove_gre66() break elif server_type == "7": remove_gre67() break elif server_type == "8": remove_gre68() break elif server_type == "9": remove_gre69() break elif server_type == "10": remove_gre610() break elif server_type == "11": rmv3_q() break elif server_type == "0": clear() rmv_gre6() break else: print("Invalid choice.") def rmv3_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gre6{}".format(i) globals()[menu_name]() def ir_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[93mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[93mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "6": rmv4_q() break elif server_type == "0": clear() rmv_gre6() break else: print("Invalid choice.") def rmv4_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_gre6{}".format(i) globals()[menu_name]() # remove gen multi def rmv_gen_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN \033[96mGen UDP|Native\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN \033[96mGen UDP|Native\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("3. \033[93m[1]Kharej | [5]IRAN \033[96mGen Gre6\033[0m") print("4. \033[92m[5]Kharej | [1]IRAN \033[96mGen Gre6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("5. \033[92m[5]Kharej | [1]IRAN \033[96m+ IPSEC\033[0m") print("6. \033[93m[1]Kharej | [5]IRAN \033[96m+ IPSEC\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_gen_multi() break elif server_type == "2": ir_gen_multi() break elif server_type == "3": ir_gen_multigre() break elif server_type == "4": kh_gen_multigre() break elif server_type == "5": kh_gen_multisec() break elif server_type == "6": ir_gen_multisec() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def kh_gen_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": rmv1m_qgen() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv1m_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}_uninstall".format(i) globals()[menu_name]() # gre def kh_gen_multigre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": rmv1m_qgengre() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv1m_qgengre(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}gre_uninstall".format(i) globals()[menu_name]() # sec def kh_gen_multisec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": rmv1m_qgensec() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv1m_qgensec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}_uninstall_sec".format(i) globals()[menu_name]() def ir_gen_multi(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": rmv2m_qgen() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv2m_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}_uninstall".format(i) globals()[menu_name]() # gre def ir_gen_multigre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": rmv2m_qgengre() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv2m_qgengre(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}gre_uninstall".format(i) globals()[menu_name]() # sec def ir_gen_multisec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": rmv2m_qgensec() break elif server_type == "0": clear() rmv_gen_multi() break else: print("Invalid choice.") def rmv2m_qgensec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genz{}_uninstall_sec".format(i) globals()[menu_name]() # remove def remote_ip_gen1(): gen_path = "/etc/sys1.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz1gre_uninstall(): os.system("clear") remove_gre61() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen1() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b481::1") delufw("fd1d:fc98:b73e:b481::2") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2001:db3::1") delufw("2001:db3::2") try: if ( subprocess.call( "test -f /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys1.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping1_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen1 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz1_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen1() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b481::1") delufw("fd1d:fc98:b73e:b481::2") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2001:db3::1") delufw("2001:db3::2") try: if ( subprocess.call( "test -f /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys1.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping1_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen1 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz1_uninstall_sec(): os.system("clear") remove_gre61() delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen1() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b481::1") delufw("fd1d:fc98:b73e:b481::2") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2001:db3::1") delufw("2001:db3::2") try: if ( subprocess.call( "test -f /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys1.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping1_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen1 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo apt purge strongswan -y > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz1u_uninstall_sec(): os.system("clear") delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen1() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b481::1") delufw("fd1d:fc98:b73e:b481::2") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2001:db3::1") delufw("2001:db3::2") try: if ( subprocess.call( "test -f /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys1.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys1.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping1_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping1_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen1 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo apt purge strongswan -y > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # 2 def remote_ip_gen2(): gen_path = "/etc/sys2.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz2gre_uninstall(): os.system("clear") remove_gre62() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen2() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b581::1") delufw("fd1d:fc98:b73e:b581::2") delufw("2002:841a::1") delufw("2002:841a::2") delufw("2001:db4::1") delufw("2001:db4::2") try: if ( subprocess.call( "test -f /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys2.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping2_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen2 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz2_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen2() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b581::1") delufw("fd1d:fc98:b73e:b581::2") delufw("2002:841a::1") delufw("2002:841a::2") delufw("2001:db4::1") delufw("2001:db4::2") try: if ( subprocess.call( "test -f /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys2.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping2_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen2 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz2_uninstall_sec(): os.system("clear") remove_gre62() delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen2() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b581::1") delufw("fd1d:fc98:b73e:b581::2") delufw("2002:841a::1") delufw("2002:841a::2") delufw("2001:db4::1") delufw("2001:db4::2") try: if ( subprocess.call( "test -f /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys2.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping2_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "sudo ip link delete azumigen2 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz2u_uninstall_sec(): os.system("clear") delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen2() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b581::1") delufw("fd1d:fc98:b73e:b581::2") delufw("2002:841a::1") delufw("2002:841a::2") delufw("2001:db4::1") delufw("2001:db4::2") try: if ( subprocess.call( "test -f /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys2.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys2.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping2_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping2_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "sudo ip link delete azumigen2 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # 3 def remote_ip_gen3(): gen_path = "/etc/sys3.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz3gre_uninstall(): os.system("clear") remove_gre63() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen3() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b681::1") delufw("fd1d:fc98:b73e:b681::2") delufw("2002:851a::1") delufw("2002:851a::2") delufw("2001:db5::1") delufw("2001:db5::2") try: if ( subprocess.call( "test -f /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys3.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping3_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen3 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz3_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen3() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b681::1") delufw("fd1d:fc98:b73e:b681::2") delufw("2002:851a::1") delufw("2002:851a::2") delufw("2001:db5::1") delufw("2001:db5::2") try: if ( subprocess.call( "test -f /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys3.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping3_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen3 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz3_uninstall_sec(): os.system("clear") remove_gre63() delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen3() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b681::1") delufw("fd1d:fc98:b73e:b681::2") delufw("2002:851a::1") delufw("2002:851a::2") delufw("2001:db5::1") delufw("2001:db5::2") try: if ( subprocess.call( "test -f /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys3.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping3_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen3 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz3u_uninstall_sec(): os.system("clear") delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen3() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b681::1") delufw("fd1d:fc98:b73e:b681::2") delufw("2002:851a::1") delufw("2002:851a::2") delufw("2001:db5::1") delufw("2001:db5::2") try: if ( subprocess.call( "test -f /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys3.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys3.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping3_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping3_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen3 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # 4 def remote_ip_gen4(): gen_path = "/etc/sys4.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz4gre_uninstall(): os.system("clear") remove_gre64() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen4() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b781::1") delufw("fd1d:fc98:b73e:b781::2") delufw("2002:861a::1") delufw("2002:861a::2") delufw("2001:db6::1") delufw("2001:db6::2") try: if ( subprocess.call( "test -f /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys4.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping4_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen4 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz4_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen4() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b781::1") delufw("fd1d:fc98:b73e:b781::2") delufw("2002:861a::1") delufw("2002:861a::2") delufw("2001:db6::1") delufw("2001:db6::2") try: if ( subprocess.call( "test -f /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys4.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping4_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen4 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz4_uninstall_sec(): os.system("clear") remove_gre64() delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen4() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b781::1") delufw("fd1d:fc98:b73e:b781::2") delufw("2002:861a::1") delufw("2002:861a::2") delufw("2001:db6::1") delufw("2001:db6::2") try: if ( subprocess.call( "test -f /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys4.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping4_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen4 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz4u_uninstall_sec(): os.system("clear") delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen4() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b781::1") delufw("fd1d:fc98:b73e:b781::2") delufw("2002:861a::1") delufw("2002:861a::2") delufw("2001:db6::1") delufw("2001:db6::2") try: if ( subprocess.call( "test -f /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys4.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys4.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping4_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping4_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen4 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # 5 def remote_ip_gen5(): gen_path = "/etc/sys5.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz5gre_uninstall(): os.system("clear") remove_gre65() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen5() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b881::1") delufw("fd1d:fc98:b73e:b881::2") delufw("2002:871a::1") delufw("2002:871a::2") delufw("2001:db7::1") delufw("2001:db7::2") try: if ( subprocess.call( "test -f /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys5.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping5_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen5 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz5_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen5() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b881::1") delufw("fd1d:fc98:b73e:b881::2") delufw("2002:871a::1") delufw("2002:871a::2") delufw("2001:db7::1") delufw("2001:db7::2") try: if ( subprocess.call( "test -f /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys5.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping5_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen5 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz5_uninstall_sec(): os.system("clear") remove_gre65() delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen5() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b881::1") delufw("fd1d:fc98:b73e:b881::2") delufw("2002:871a::1") delufw("2002:871a::2") delufw("2001:db7::1") delufw("2001:db7::2") try: if ( subprocess.call( "test -f /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys5.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping5_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen5 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def genz5u_uninstall_sec(): os.system("clear") delete_cron1() delete_cron2() delete_cron3() delete_cron4() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remote_ip = remote_ip_gen5() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) delufw("fd1d:fc98:b73e:b881::1") delufw("fd1d:fc98:b73e:b881::2") delufw("2002:871a::1") delufw("2002:871a::2") delufw("2001:db7::1") delufw("2001:db7::2") try: if ( subprocess.call( "test -f /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys5.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys5.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping5_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping5_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen5 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def remove_gre61(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre61.sh", shell=True) == 0: subprocess.run("rm /etc/gre61.sh", shell=True) if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre61.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip1.sh", shell=True) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip1.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip1.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig61 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig61 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre62(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre62.sh", shell=True) == 0: subprocess.run("rm /etc/gre62.sh", shell=True) if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre62.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip2.sh", shell=True) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip2.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip2.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip2.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig62 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig62 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre63(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre63.sh", shell=True) == 0: subprocess.run("rm /etc/gre63.sh", shell=True) if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre63.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip3.sh", shell=True) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip3.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip3.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip3.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig63 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig63 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre64(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre64.sh", shell=True) == 0: subprocess.run("rm /etc/gre64.sh", shell=True) if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre64.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip4.sh", shell=True) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip4.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip4.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip4.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig64 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig64 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre65(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre65.sh", shell=True) == 0: subprocess.run("rm /etc/gre65.sh", shell=True) if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre65.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip5.sh", shell=True) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip5.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip5.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip5.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig65 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig65 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre66(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre66.sh", shell=True) == 0: subprocess.run("rm /etc/gre66.sh", shell=True) if subprocess.call("test -f /etc/private6.sh", shell=True) == 0: subprocess.run("rm /etc/private6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre66.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v66.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip6.sh", shell=True) subprocess.run( "systemctl disable ping_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip6.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip6.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig66 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig66 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre67(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre67.sh", shell=True) == 0: subprocess.run("rm /etc/gre67.sh", shell=True) if subprocess.call("test -f /etc/private7.sh", shell=True) == 0: subprocess.run("rm /etc/private7.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre67.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private7.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v67.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip7.sh", shell=True) subprocess.run( "systemctl disable ping_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip7.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip7.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip7.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi7 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi7 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig67 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig67 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre68(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre68.sh", shell=True) == 0: subprocess.run("rm /etc/gre68.sh", shell=True) if subprocess.call("test -f /etc/private8.sh", shell=True) == 0: subprocess.run("rm /etc/private8.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre68.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private8.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v68.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip8.sh", shell=True) subprocess.run( "systemctl disable ping_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip8.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip8.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip8.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi8 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi8 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig68 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig68 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre69(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre69.sh", shell=True) == 0: subprocess.run("rm /etc/gre69.sh", shell=True) if subprocess.call("test -f /etc/private9.sh", shell=True) == 0: subprocess.run("rm /etc/private9.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre69.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private9.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v69.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip9.sh", shell=True) subprocess.run( "systemctl disable ping_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip9.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip9.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip9.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi9 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig69 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig69 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre610(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre610.sh", shell=True) == 0: subprocess.run("rm /etc/gre610.sh", shell=True) if subprocess.call("test -f /etc/private10.sh", shell=True) == 0: subprocess.run("rm /etc/private10.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre610.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private10.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v610.sh", shell=True) time.sleep(1) subprocess.run("sudo rm /etc/ping_ip10.sh", shell=True) subprocess.run( "systemctl disable ping_v610.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v610.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run( "systemctl disable ping_ip10.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_ip10.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip10.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi9 > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumig610 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig610 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def rmv_private_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private + IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[5] | IRAN[1]\033[0m") print("2. \033[93mKharej[1] | IRAN[5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_private_sec() break elif server_type == "2": ir_private_sec() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def rmv5_qprivate_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}_sec".format(i) globals()[menu_name]() def kh_private_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() break elif server_type == "2": remove_private2_sec() break elif server_type == "3": remove_private3_sec() break elif server_type == "4": remove_private4_sec() break elif server_type == "5": remove_private5_sec() break elif server_type == "6": rmv5_qprivate_sec() break elif server_type == "0": clear() rmv_private_sec() break else: print("Invalid choice.") def ir_private_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[93mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() break elif server_type == "2": remove_private2_sec() break elif server_type == "3": remove_private3_sec() break elif server_type == "4": remove_private4_sec() break elif server_type == "5": remove_private5_sec() break elif server_type == "6": rmv6_qprivate_sec() break elif server_type == "0": clear() rmv_private_sec() break else: print("Invalid choice.") def rmv6_qprivate_sec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}_sec".format(i) globals()[menu_name]() def remove_private1_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec1.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec2.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec3.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec4.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5_sec(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ipsec5.conf > /dev/null 2>&1", shell=True) subprocess.run("sudo rm /etc/ipsec.secrets > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strong-azumi1 > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/strong-azumi1.service > /dev/null 2>&1", shell=True ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) subprocess.run("apt purge strongswan -y > /dev/null", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def rmv_private(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[10] | IRAN[1]\033[0m") print("2. \033[93mKharej[1] | IRAN[5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kh_private() break elif server_type == "2": ir_private() break elif server_type == "0": clear() remove2_menu() break else: print("Invalid choice.") def rmv5_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}".format(i) globals()[menu_name]() def kh_private(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "6": remove_private6() break elif server_type == "7": remove_private7() break elif server_type == "8": remove_private8() break elif server_type == "9": remove_private9() break elif server_type == "10": remove_private10() break elif server_type == "11": rmv5_q() break elif server_type == "0": clear() rmv_private() break else: print("Invalid choice.") def ir_private(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[93mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "6": rmv6_q() break elif server_type == "0": clear() rmv_private() break else: print("Invalid choice.") def rmv6_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}".format(i) globals()[menu_name]() def remove_private1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private1.sh", shell=True) == 0: subprocess.run("rm /etc/private1.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private1.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi1 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private2.sh", shell=True) == 0: subprocess.run("rm /etc/private2.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private2.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi2 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private3.sh", shell=True) == 0: subprocess.run("rm /etc/private3.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private3.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi3 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private4.sh", shell=True) == 0: subprocess.run("rm /etc/private4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private4.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi4 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private5.sh", shell=True) == 0: subprocess.run("rm /etc/private5.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private5.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi5 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private6.sh", shell=True) == 0: subprocess.run("rm /etc/private6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private7.sh", shell=True) == 0: subprocess.run("rm /etc/private7.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private7.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi7 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private8.sh", shell=True) == 0: subprocess.run("rm /etc/private8.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private8.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi8 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private9.sh", shell=True) == 0: subprocess.run("rm /etc/private9.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private9.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi9 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/private10.sh", shell=True) == 0: subprocess.run("rm /etc/private10.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private10.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable ping_v610.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v610.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi10 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private1s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates11.sh", shell=True) == 0: subprocess.run("rm /etc/privates11.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates11.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates12.sh", shell=True) == 0: subprocess.run("rm /etc/privates12.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates12.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates13.sh", shell=True) == 0: subprocess.run("rm /etc/privates13.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates13.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates14.sh", shell=True) == 0: subprocess.run("rm /etc/privates14.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates14.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates15.sh", shell=True) == 0: subprocess.run("rm /etc/privates15.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates15.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates16.sh", shell=True) == 0: subprocess.run("rm /etc/privates16.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates16.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates17.sh", shell=True) == 0: subprocess.run("rm /etc/privates17.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates17.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates18.sh", shell=True) == 0: subprocess.run("rm /etc/privates18.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates18.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates19.sh", shell=True) == 0: subprocess.run("rm /etc/privates19.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates19.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s1(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates110.sh", shell=True) == 0: subprocess.run("rm /etc/privates110.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates110.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings1_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings1_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private1s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates11.sh", shell=True) == 0: subprocess.run("rm /etc/privates11.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates11.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates12.sh", shell=True) == 0: subprocess.run("rm /etc/privates12.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates12.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates13.sh", shell=True) == 0: subprocess.run("rm /etc/privates13.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates13.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates14.sh", shell=True) == 0: subprocess.run("rm /etc/privates14.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates14.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates15.sh", shell=True) == 0: subprocess.run("rm /etc/privates15.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates15.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates16.sh", shell=True) == 0: subprocess.run("rm /etc/privates16.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates16.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates17.sh", shell=True) == 0: subprocess.run("rm /etc/privates17.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates17.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates18.sh", shell=True) == 0: subprocess.run("rm /etc/privates18.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates18.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates19.sh", shell=True) == 0: subprocess.run("rm /etc/privates19.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates19.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings1_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings1_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s1i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates110.sh", shell=True) == 0: subprocess.run("rm /etc/privates110.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates110.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings1_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings1_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings1_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings1_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran1config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran1config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) ## gre6 ipsec def config_gre6k1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn gre61 left=%defaultroute leftsubnet=2002:801a::1/64 leftid=2002:801a::1 right=2002:801a::2 rightsubnet=2002:801a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:801a::2 2002:801a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6k2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre62 left=%defaultroute leftsubnet=2002:811a::1/64 leftid=2002:811a::1 right=2002:811a::2 rightsubnet=2002:811a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::2 2002:811a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6k3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre63 left=%defaultroute leftsubnet=2002:821a::1/64 leftid=2002:821a::1 right=2002:821a::2 rightsubnet=2002:821a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:821a::2 2002:821a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6k4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre64 left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6k5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre65 left=%defaultroute leftsubnet=2002:841a::1/64 leftid=2002:841a::1 right=2002:841a::2 rightsubnet=2002:841a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:841a::2 2002:841a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre61 left=%defaultroute leftsubnet=2002:801a::2/64 leftid=2002:801a::2 right=2002:801a::1 rightsubnet=2002:801a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:801a::1 2002:801a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gre62 left=%defaultroute leftsubnet=2002:811a::2/64 leftid=2002:811a::2 right=2002:811a::1 rightsubnet=2002:811a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::1 2002:811a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn gre63 left=%defaultroute leftsubnet=2002:821a::2/64 leftid=2002:821a::2 right=2002:821a::1 rightsubnet=2002:821a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:821a::1 2002:821a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn gre64 left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2002:841a::2/64 leftid=2002:841a::2 right=2002:841a::1 rightsubnet=2002:841a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:841a::1 2002:841a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6k(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyouarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::1/64\n") f.write(f" leftid=2002:8{i+0}1a::1\n") f.write(f" right=2002:8{i+0}1a::2\n") f.write(f" rightsubnet=2002:8{i+0}1a::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::2 2002:8{i+0}1a::1 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_gre6i(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::2/64\n") f.write(f" leftid=2002:8{i+0}1a::2\n") f.write(f" right=2002:8{i+0}1a::1\n") f.write(f" rightsubnet=2002:8{i+0}1a::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::1 2002:8{i+0}1a::2 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def gre6_mnu_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSec \033[92m Multiple Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKHAREJ\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKHAREJ\033[92m[1] \033[93mIRAN\033[92m[5]\033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh_ipsec() break elif server_type == "2": gre6_ir_ipsec() break elif server_type == "3": choose_reset2() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def gre6_kh_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSec\033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_gre61_ipsec() restart_forced_strongazumi() break elif server_type == "2": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_gre62_ipsec() restart_forced_strongazumi() break elif server_type == "3": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_gre63_ipsec() restart_forced_strongazumi() break elif server_type == "4": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_gre64_ipsec() restart_forced_strongazumi() break elif server_type == "5": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_gre65_ipsec() restart_forced_strongazumi() break elif server_type == "6": gre6_reset_rmvmnu() enable_reset_ipsec() kharejgre_qipsec() break elif server_type == "0": os.system("clear") gre6_mnu_ipsec() break else: print("Invalid choice.") def kharejgre_qipsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "iran_gre6{}_ipsec".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def kharejgre_qipsec_edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i(psk, num_servers) restart_forced_strongazumi() # edit2 def kharejgre_qipsec_edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_gre6i(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def gre6_ir_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 + IPSec \033[92m[3]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_gre61_ipsec() restart_forced_strongazumi() break elif server_type == "2": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_gre62_ipsec() restart_forced_strongazumi() break elif server_type == "3": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_gre63_ipsec() restart_forced_strongazumi() break elif server_type == "4": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_gre64_ipsec() restart_forced_strongazumi() break elif server_type == "5": gre6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_gre65_ipsec() restart_forced_strongazumi() break elif server_type == "6": gre6_reset_rmvmnu() enable_reset_ipsec() irangre_qipsec() break elif server_type == "0": os.system("clear") gre6_mnu_ipsec() break else: print("Invalid choice.") def irangre_qipsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "kharej2_gre6{}_ipsec".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def irangre_qipsec_edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k(psk, num_servers) restart_forced_strongazumi() # edit2 def irangre_qipsec_edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_gre6k(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def kharej_gre61_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[1]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k1(psk) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre61_kharejsec() sleep(1) ## kharej1 for iran 1 def kharej2_gre61_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[1]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre61_kharejsec() sleep(1) # edit def kharej2_gre61_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[1]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k1(psk) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre61_kharejsec() sleep(1) def kharej_gre62_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[2]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k2(psk) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre62_kharejsec() sleep(1) ## kharej 2 for iran 2 def kharej2_gre62_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[2]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre62_kharejsec() sleep(1) def kharej_gre63_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[3]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k3(psk) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre63_kharejsec() sleep(1) ## kharej 3 for iran 3 def kharej2_gre63_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[3]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre63_kharejsec() sleep(1) def kharej_gre64_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[4]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k4(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre64_kharejsec() sleep(1) ## kharej 4 for iran 4 def kharej2_gre64_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[4]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre64_kharejsec() sleep(1) def kharej_gre65_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[5]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k5(psk) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre65_kharejsec() sleep(1) ## kharej 5 for iran 5 def kharej2_gre65_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[92mKharej[5]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre65_kharejsec() sleep(1) def iran_gre61_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre61_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # edit def iran_gre61_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i1(psk) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre61_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ##default route iran1 command def iran2_gre61_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m [1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i1(psk) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre61_iran2sec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def iran_gre62_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre62_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route iran 2 menu def iran2_gre62_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i2(psk) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre62_iran2sec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def iran_gre63_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre63_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre63_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i3(psk) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre63_iran2sec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def iran_gre64_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre64_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre64_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i4(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre64_iran2sec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def iran_gre65_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre65_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre65_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 + IPSec \033[96m Server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i5(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre65_iran2sec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # gretap native def gretapnm(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN\033[0m") print("2. \033[93m[1] Kharej [5] IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapmu_k() break elif server_type == "2": gre6tapmu_i() break elif server_type == "3": clear() gre6tapmulti_mnu break else: print("Invalid choice.") def gre6tapmu_k(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[92mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[96mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_k1() break elif server_type == "2": gre6tap_k2() break elif server_type == "3": gre6tap_k3() break elif server_type == "4": gre6tap_k4() break elif server_type == "5": gre6tap_k5() break elif server_type == "6": gre6tap_k6() break elif server_type == "7": gre6tap_k7() break elif server_type == "8": gre6tap_k8() break elif server_type == "9": gre6tap_k9() break elif server_type == "10": gre6tap_k10() break elif server_type == "11": irangretap_q() break elif server_type == "0": clear() gretapnm() break else: print("Invalid choice.") def irangretap_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6tap2_i{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def gre6tapmu_i(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_i1() break elif server_type == "2": gre6tap_i2() break elif server_type == "3": gre6tap_i3() break elif server_type == "4": gre6tap_i4() break elif server_type == "5": gre6tap_i5() break elif server_type == "6": kharejgretap_q() break elif server_type == "0": clear() gretapnm() break else: print("Invalid choice.") def kharejgretap_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6tap2_k{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def gre6tapk_tunnel1(): global local_ip, remote_ip file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel1(): global local_ip, remote_ip gre6tapk_tunnel1() ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def gre6tap_k1(): global local_ip, remote_ip display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel1(): global local_ip, remote_ip file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel1(): global local_ip, remote_ip gre6tapi_tunnel1() ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def gre6tap_i1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 2native def gre6tapk_tunnel2(): global local_ip, remote_ip file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel2(): global local_ip, remote_ip gre6tapk_tunnel2() ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def gre6tap_k2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel2(): global local_ip, remote_ip file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:811a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel2(): global local_ip, remote_ip gre6tapi_tunnel2() ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def gre6tap_i2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 3native def gre6tapk_tunnel3(): global local_ip, remote_ip file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:821a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel3(): global local_ip, remote_ip gre6tapk_tunnel3() ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def gre6tap_k3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel3(): global local_ip, remote_ip file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:821a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel3(): global local_ip, remote_ip gre6tapi_tunnel3() ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def gre6tap_i3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end def create_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def create_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ping_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def ping_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def gre64_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre64.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre64.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre65_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre65.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre65.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) # 4native def gre6tapk_tunnel4(): global local_ip, remote_ip file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:831a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel4(): global local_ip, remote_ip gre6tapk_tunnel4() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def gre6tap_k4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel4(): global local_ip, remote_ip file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:831a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel4(): global local_ip, remote_ip gre6tapi_tunnel4() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def gre6tap_i4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 5native def gre6tapk_tunnel5(): global local_ip, remote_ip file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:841a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel5(): global local_ip, remote_ip gre6tapk_tunnel5() ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def gre6tap_k5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel5(): global local_ip, remote_ip file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:841a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel5(): global local_ip, remote_ip gre6tapi_tunnel5() ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def gre6tap_i5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 6native def gre6tapk_tunnel6(): global local_ip, remote_ip file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig66 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:851a::1/64 dev azumig66\n") f.write("ip link set azumig66 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel6(): global local_ip, remote_ip gre6tapk_tunnel6() ip_address = "2002:851a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping6_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre66_service() gre66_cronjob() def gre6tap_k6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[6]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[6]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel6(): global local_ip, remote_ip file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig66 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:851a::2/64 dev azumig66\n") f.write("ip link set azumig66 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel6(): global local_ip, remote_ip gre6tapi_tunnel6() ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 iran_ping6_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre66_service() gre66_cronjob() def gre6tap_i6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[6]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[6]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 7native def gre6tapk_tunnel7(): global local_ip, remote_ip file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig67 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:861a::1/64 dev azumig67\n") f.write("ip link set azumig67 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel7(): global local_ip, remote_ip gre6tapk_tunnel7() ip_address = "2002:861a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping7_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre67_service() gre67_cronjob() def gre6tap_k7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[7]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[7]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel7(): global local_ip, remote_ip file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig67 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:861a::2/64 dev azumig67\n") f.write("ip link set azumig67 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel7(): global local_ip, remote_ip gre6tapi_tunnel7() ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 iran_ping7_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre67_service() gre67_cronjob() def gre6tap_i7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[7]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[7]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 8native def gre6tapk_tunnel8(): global local_ip, remote_ip file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig68 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:871a::1/64 dev azumig68\n") f.write("ip link set azumig68 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel8(): global local_ip, remote_ip gre6tapk_tunnel8() ip_address = "2002:871a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping8_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre68_service() gre68_cronjob() def gre6tap_k8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[8]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[8]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel8(): global local_ip, remote_ip file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig68 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:871a::2/64 dev azumig68\n") f.write("ip link set azumig68 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel8(): global local_ip, remote_ip gre6tapi_tunnel8() ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 iran_ping8_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre68_service() gre68_cronjob() def gre6tap_i8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[8]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[8]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 9native def gre6tapk_tunnel9(): global local_ip, remote_ip file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig69 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:881a::1/64 dev azumig69\n") f.write("ip link set azumig69 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel9(): global local_ip, remote_ip gre6tapk_tunnel9() ip_address = "2002:881a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping8_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre69_service() gre69_cronjob() def gre6tap_k9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[9]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[9]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel9(): global local_ip, remote_ip file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig69 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:881a::2/64 dev azumig69\n") f.write("ip link set azumig69 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel9(): global local_ip, remote_ip gre6tapi_tunnel9() ip_address = "2002:881a::1" # kharejip max_pings = 3 interval = 2 iran_ping9_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre69_service() gre69_cronjob() def gre6tap_i9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[9]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[9]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 10native def gre6tapk_tunnel10(): global local_ip, remote_ip file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig610 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:891a::1/64 dev azumig610\n") f.write("ip link set azumig610 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def kharej_gre6tap_tunnel10(): global local_ip, remote_ip gre6tapk_tunnel10() ip_address = "2002:891a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping10_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre610_service() gre610_cronjob() def gre6tap_k10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[10]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[10]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tapi_tunnel10(): global local_ip, remote_ip file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig610 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write(f"ip -6 addr add 2002:891a::2/64 dev azumig610\n") f.write("ip link set azumig610 up\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(["bash", file_path], check=True) def iran_gre6tap_tunnel10(): global local_ip, remote_ip gre6tapi_tunnel10() ip_address = "2002:891a::1" # kharejip max_pings = 3 interval = 2 iran_ping10_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre610_service() gre610_cronjob() def gre6tap_i10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[10]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[10]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ##end ## 11 def gre6_mnu_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6 \033[92m Multiple Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKHAREJ\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKHAREJ\033[92m[1] \033[93mIRAN\033[92m[5]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh_ip() break elif server_type == "2": gre6_ir_ip() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def gre6_kh_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnu() kharej_gre61_menu() break elif server_type == "2": gre6_reset_rmvmnu() kharej_gre62_menu() break elif server_type == "3": gre6_reset_rmvmnu() kharej_gre63_menu() break elif server_type == "4": gre6_reset_rmvmnu() kharej_gre64_menu() break elif server_type == "5": gre6_reset_rmvmnu() kharej_gre65_menu() break elif server_type == "6": gre6_reset_rmvmnu() kharej_gre66_menu() break elif server_type == "7": gre6_reset_rmvmnu() kharej_gre67_menu() break elif server_type == "8": gre6_reset_rmvmnu() kharej_gre68_menu() break elif server_type == "9": gre6_reset_rmvmnu() kharej_gre69_menu() break elif server_type == "10": gre6_reset_rmvmnu() kharej_gre610_menu() break elif server_type == "11": gre6_reset_rmvmnu() kharejgre_q() break elif server_type == "0": os.system("clear") gre6_mnu_ip() break else: print("Invalid choice.") def kharejgre_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran_gre6{}_menu".format(i) globals()[menu_name]() def gre6_ir_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGRE6 \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran2_gre61_menu() break elif server_type == "2": iran2_gre62_menu() break elif server_type == "3": iran2_gre63_menu() break elif server_type == "4": iran2_gre64_menu() break elif server_type == "5": iran2_gre65_menu() break elif server_type == "6": irangre_q() break elif server_type == "0": os.system("clear") gre6_mnu_ip() break else: print("Invalid choice.") def irangre_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "kharej2_gre6{}_menu".format(i) globals()[menu_name]() ##kharej1 def run1_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:801b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej1_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:801b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre61_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre61.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre61.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def gre61_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:80{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre61_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre61_kharej(): remote_ip = "2002:801b::2" # iran-ip local_ip = "2002:801b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre61_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def gre61_kharejsec(): remote_ip = "2002:801b::2" # iran-ip local_ip = "2002:801b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre61_tunnelsec(remote_ip, local_ip) ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def kharej_gre61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[1]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre61_kharej() sleep(1) ## kharej1 for iran 1 def kharej2_gre61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[1]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre61_kharej() sleep(1) ##kharej2 def run2_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:811b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v62.service"]) subprocess.run(["systemctl", "start", "ping_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v62.service"]) def display_kharej2_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:811b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron2_job(): file_path = "/etc/private2.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre62_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre62.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre62.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def gre62_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:81{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre62_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre62_kharej(): remote_ip = "2002:811b::2" # iran-ip local_ip = "2002:811b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre62_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def gre62_kharejsec(): remote_ip = "2002:811b::2" # iran-ip local_ip = "2002:811b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre62_tunnelsec(remote_ip, local_ip) ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def kharej_gre62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[2]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre62_kharej() sleep(1) ## kharej 2 for iran 2 def kharej2_gre62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[2]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre62_kharej() sleep(1) # edit def kharej2_gre62_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[2]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k2(psk) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre62_kharej() sleep(1) ##kharej3 def run3_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:821b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v63.service"]) subprocess.run(["systemctl", "start", "ping_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v63.service"]) def display_kharej3_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:821b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron3_job(): file_path = "/etc/private3.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre63_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre63.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre63.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def gre63_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:82{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre63_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre63_kharej(): remote_ip = "2002:821b::2" # iran-ip local_ip = "2002:821b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre63_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def gre63_kharejsec(): remote_ip = "2002:821b::2" # iran-ip local_ip = "2002:821b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre63_tunnelsec(remote_ip, local_ip) ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def kharej_gre63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[3]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre63_kharej() sleep(1) ## kharej 3 for iran 3 def kharej2_gre63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[3]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre63_kharej() sleep(1) # edit def kharej2_gre63_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[3]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k3(psk) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre63_kharej() sleep(1) # kharej 4 def run4_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:831b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v64.service"]) subprocess.run(["systemctl", "start", "ping_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v64.service"]) def display_kharej4_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron4_job(): file_path = "/etc/private4.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre64_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre64.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre64.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def gre64_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre64_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre64_kharej(): remote_ip = "2002:831b::2" # iran-ip local_ip = "2002:831b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre64_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def gre64_kharejsec(): remote_ip = "2002:831b::2" # iran-ip local_ip = "2002:831b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre64_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def kharej_gre64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[4]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre64_kharej() sleep(1) ## kharej 4 for iran 4 def kharej2_gre64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[4]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre64_kharej() sleep(1) # edit def kharej2_gre64_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[4]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k4(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre64_kharej() sleep(1) # kharej 5 def run5_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:841b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v65.service"]) subprocess.run(["systemctl", "start", "ping_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v65.service"]) def display_kharej5_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:841b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron5_job(): file_path = "/etc/private5.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre65_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre65.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre65.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def gre65_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:84{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre65_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre65_kharej(): remote_ip = "2002:841b::2" # iran-ip local_ip = "2002:841b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre65_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def gre65_kharejsec(): remote_ip = "2002:841b::2" # iran-ip local_ip = "2002:841b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre65_tunnelsec(remote_ip, local_ip) ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def kharej_gre65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[5]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre65_kharej() sleep(1) ## kharej 5 for iran 5 def kharej2_gre65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[5]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre65_kharej() sleep(1) # edit def kharej2_gre65_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[5]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6k5(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre65_kharej() sleep(1) # kharej 6 def run6_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:851b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v66.service"]) subprocess.run(["systemctl", "start", "ping_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v66.service"]) def display_kharej6_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:851b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron6_job(): file_path = "/etc/private6.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre66_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre66.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre66.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip6.service"]) subprocess.run(["systemctl", "start", "ping_ip6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip6.service"]) def gre66_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig66 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:851a::1/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig66 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:851a::2/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:85{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}" with open("/etc/gre66.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 6:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:851a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping6_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip6.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre66_kharej(): remote_ip = "2002:851b::2" # iran-ip local_ip = "2002:851b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre66_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:851a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping6_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre66_service() gre66_cronjob() def kharej_gre66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[6]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::2/64", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002:851b::2/64 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre66_kharej() sleep(1) ## kharej 6 for iran 6 def kharej2_gre66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[6]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::2/64", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002:851b::2/64 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre66_kharej() sleep(1) # kharej 7 def run7_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:861b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v67.service"]) subprocess.run(["systemctl", "start", "ping_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v67.service"]) def display_kharej7_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:861b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron7_job(): file_path = "/etc/private7.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre67_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre67.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre67.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip7.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip7.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip7.service"]) subprocess.run(["systemctl", "start", "ping_ip7.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip7.service"]) def gre67_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig67 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:861a::1/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig67 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:861a::2/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:86{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}" with open("/etc/gre67.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 7:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:861a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping7_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip7.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre67_kharej(): remote_ip = "2002:861b::2" # iran-ip local_ip = "2002:861b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre67_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:861a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping7_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre67_service() gre67_cronjob() def kharej_gre67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[7]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::2/64", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002:861b::2/64 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre67_kharej() sleep(1) ## kharej 7 for iran 7 def kharej2_gre67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[7]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::2/64", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002:861b::2/64 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre67_kharej() sleep(1) # kharej 8 def run8_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:871b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v68.service"]) subprocess.run(["systemctl", "start", "ping_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v68.service"]) def display_kharej8_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:871b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron8_job(): file_path = "/etc/private8.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre68_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre68.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre68.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip8.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip8.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip8.service"]) subprocess.run(["systemctl", "start", "ping_ip8.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip8.service"]) def gre68_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig68 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:871a::1/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig68 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:871a::2/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:87{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}" with open("/etc/gre68.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 8:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:871a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping8_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip8.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre68_kharej(): remote_ip = "2002:871b::2" # iran-ip local_ip = "2002:871b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre68_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:871a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping8_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre68_service() gre68_cronjob() def kharej_gre68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[8]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::2/64", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002:871b::2/64 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre68_kharej() sleep(1) ## kharej 8 for iran 8 def kharej2_gre68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[8]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::2/64", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002:871b::2/64 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre68_kharej() sleep(1) # kharej 9 def run9_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:881b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v69.service"]) subprocess.run(["systemctl", "start", "ping_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v69.service"]) def display_kharej9_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:881b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron9_job(): file_path = "/etc/private9.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre69_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre69.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre69.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip9.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip9.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip9.service"]) subprocess.run(["systemctl", "start", "ping_ip9.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip9.service"]) def gre69_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig69 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:881a::1/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig69 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:881a::2/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:88{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}" with open("/etc/gre69.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 9:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:881a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping9_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip9.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre69_kharej(): remote_ip = "2002:881b::2" # iran-ip local_ip = "2002:881b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre69_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:881a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping9_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre69_service() gre69_cronjob() def kharej_gre69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[9]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::2/64", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002:881b::2/64 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre69_kharej() sleep(1) ## kharej 9 for iran 9 def kharej2_gre69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[9]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::2/64", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002:881b::2/64 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre69_kharej() sleep(1) # kharej 10 def run10_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:891b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v610.service"]) subprocess.run(["systemctl", "start", "ping_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v610.service"]) def display_kharej10_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:891b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron10_job(): file_path = "/etc/private10.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gre610_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre610.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre610.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip10.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip10.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip10.service"]) subprocess.run(["systemctl", "start", "ping_ip10.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip10.service"]) def gre610_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig610 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:891a::1/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig610 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:891a::2/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:89{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}" with open("/etc/gre610.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 10:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:891a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping10_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip10.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre610_kharej(): remote_ip = "2002:891b::2" # iran-ip local_ip = "2002:891b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre610_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:891a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping10_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre610_service() gre610_cronjob() def kharej_gre610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[10]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::2/64", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002:891b::2/64 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre610_kharej() sleep(1) ## kharej 10 for iran 10 def kharej2_gre610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej[10]\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::2/64", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002:891b::2/64 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre610_kharej() sleep(1) ##### IRAN gre6 server 1 def iran_ping1(): try: subprocess.run( ["ping", "-c", "2", "2002:801b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran1_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:801b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def gre61_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:80{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre61_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##default route iran server 1 def gre61_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:80{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre61_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig61 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:801a::2/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig61 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:801a::1/64 dev azumig61' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open("/etc/gre61.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:801a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre61_iran(): remote_ip = "2002:801b::1" # kharej ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre61_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def gre61_iransec(): remote_ip = "2002:801b::1" # kharej ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre61_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() ## default route iran1 def gre61_iran2(): remote_ip = "2002:801b::1" # kharej ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre61_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def gre61_iran2sec(): remote_ip = "2002:801b::1" # kharej ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre61_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def iran_gre61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE \033[96m Server\033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre61_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ##default route iran1 command def iran2_gre61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE \033[96m Server\033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m [1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre61_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ##### IRAN gre6 server 2 def iran_ping2(): try: subprocess.run( ["ping", "-c", "2", "2002:811b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran2_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:811b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def gre62_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:81{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre62_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route iran server 2 def gre62_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:81{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre62_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig62 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:811a::2/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig62 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:811a::1/64 dev azumig62' >> {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open("/etc/gre62.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre62_iran(): remote_ip = "2002:811b::1" # kharej ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre62_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def gre62_iransec(): remote_ip = "2002:811b::1" # kharej ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre62_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() # default route server iran 2 def gre62_iran2(): remote_ip = "2002:811b::1" # kharej ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre62_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def gre62_iran2sec(): remote_ip = "2002:811b::1" # kharej ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre62_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def iran_gre62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre62_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # edit def iran_gre62_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i2(psk) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre62_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route iran 2 menu def iran2_gre62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre62_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ##### IRAN gre6 server 3 def iran_ping3(): try: subprocess.run( ["ping", "-c", "2", "2002:821b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran3_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:821b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def gre63_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:82{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre63_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 3 def gre63_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:82{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig63 mtu {mtu_value}\n" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre63_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig63 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:821a::2/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig63 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:821a::1/64 dev azumig63' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig63 mtu {mtu_value}\n" with open("/etc/gre63.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre63_iran(): remote_ip = "2002:821b::1" # kharej ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre63_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def gre63_iransec(): remote_ip = "2002:821b::1" # kharej ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre63_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() ## default route iran server 3 def gre63_iran2(): remote_ip = "2002:821b::1" # kharej ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre63_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def gre63_iran2sec(): remote_ip = "2002:821b::1" # kharej ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre63_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def iran_gre63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre63_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # edit def iran_gre63_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i3(psk) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre63_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre63_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre63_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran4gre ##### IRAN gre6 server 4 def iran_ping4(): try: subprocess.run( ["ping", "-c", "2", "2002:831b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran4_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:831b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def gre64_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre64_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 4 def gre64_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig64 mtu {mtu_value}\n" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre64_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig64 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig64 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig64' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig64 mtu {mtu_value}\n" with open("/etc/gre64.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre64_iran(): remote_ip = "2002:831b::1" # kharej ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre64_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def gre64_iransec(): remote_ip = "2002:831b::1" # kharej ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre64_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() ## default route iran server 4 def gre64_iran2(): remote_ip = "2002:831b::1" # kharej ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre64_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def gre64_iran2sec(): remote_ip = "2002:831b::1" # kharej ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre64_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def iran_gre64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre64_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # edit def iran_gre64_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i4(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre64_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre64_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre64_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # editserver2 and remove # uninstall private 5 server iran 10 def priv_ir1s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates21.sh"): with open("/etc/privates21.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config1 mtu" not in line ] with open("/etc/privates21.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates21.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates22.sh"): with open("/etc/privates22.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config2 mtu" not in line ] with open("/etc/privates22.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates22.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates23.sh"): with open("/etc/privates23.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config3iran2config3 mtu" not in line ] with open("/etc/privates23.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates23.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates24.sh"): with open("/etc/privates24.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config4 mtu" not in line ] with open("/etc/privates24.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates24.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates25.sh"): with open("/etc/privates25.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config5 mtu" not in line ] with open("/etc/privates25.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates25.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates26.sh"): with open("/etc/privates26.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config6 mtu" not in line ] with open("/etc/privates26.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates26.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates27.sh"): with open("/etc/privates27.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config7 mtu" not in line ] with open("/etc/privates27.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates27.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates28.sh"): with open("/etc/privates28.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config8 mtu" not in line ] with open("/etc/privates28.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates28.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates29.sh"): with open("/etc/privates29.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config9 mtu" not in line ] with open("/etc/privates29.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates29.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates210.sh"): with open("/etc/privates210.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config10 mtu" not in line ] with open("/etc/privates210.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates210.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 3 def priv_ir1s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates31.sh"): with open("/etc/privates31.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config1 mtu" not in line ] with open("/etc/privates31.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates31.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates32.sh"): with open("/etc/privates32.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config2 mtu" not in line ] with open("/etc/privates32.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates32.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates33.sh"): with open("/etc/privates33.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config3 mtu" not in line ] with open("/etc/privates33.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates33.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates34.sh"): with open("/etc/privates34.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config4 mtu" not in line ] with open("/etc/privates34.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates34.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates35.sh"): with open("/etc/privates35.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config5 mtu" not in line ] with open("/etc/privates35.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates35.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates36.sh"): with open("/etc/privates36.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config6 mtu" not in line ] with open("/etc/privates36.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates36.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates37.sh"): with open("/etc/privates37.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config7 mtu" not in line ] with open("/etc/privates37.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates37.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates38.sh"): with open("/etc/privates38.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config8 mtu" not in line ] with open("/etc/privates38.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates38.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates39.sh"): with open("/etc/privates39.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config9 mtu" not in line ] with open("/etc/privates39.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates39.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates310.sh"): with open("/etc/privates310.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config10 mtu" not in line ] with open("/etc/privates310.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates310.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 4 def priv_ir1s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates41.sh"): with open("/etc/privates41.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config1 mtu" not in line ] with open("/etc/privates41.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates41.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates42.sh"): with open("/etc/privates42.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config2 mtu" not in line ] with open("/etc/privates42.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates42.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates43.sh"): with open("/etc/privates43.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config3 mtu" not in line ] with open("/etc/privates43.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates43.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates44.sh"): with open("/etc/privates44.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config4 mtu" not in line ] with open("/etc/privates44.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates44.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates45.sh"): with open("/etc/privates45.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config5 mtu" not in line ] with open("/etc/privates45.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates45.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates46.sh"): with open("/etc/privates46.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config6 mtu" not in line ] with open("/etc/privates46.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates46.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates47.sh"): with open("/etc/privates47.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config7 mtu" not in line ] with open("/etc/privates47.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates47.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates48.sh"): with open("/etc/privates48.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config8 mtu" not in line ] with open("/etc/privates48.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates48.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates49.sh"): with open("/etc/privates49.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config9 mtu" not in line ] with open("/etc/privates49.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates49.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates410.sh"): with open("/etc/privates410.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config10 mtu" not in line ] with open("/etc/privates410.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates410.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 5 def priv_ir1s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates51.sh"): with open("/etc/privates51.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config1 mtu" not in line ] with open("/etc/privates51.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates51.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates52.sh"): with open("/etc/privates52.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config2 mtu" not in line ] with open("/etc/privates52.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates52.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates53.sh"): with open("/etc/privates53.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config3 mtu" not in line ] with open("/etc/privates53.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates53.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates54.sh"): with open("/etc/privates54.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config4 mtu" not in line ] with open("/etc/privates54.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates54.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates55.sh"): with open("/etc/privates55.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config5 mtu" not in line ] with open("/etc/privates55.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates55.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates56.sh"): with open("/etc/privates56.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config6 mtu" not in line ] with open("/etc/privates56.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates56.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates57.sh"): with open("/etc/privates57.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config7 mtu" not in line ] with open("/etc/privates57.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates57.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates58.sh"): with open("/etc/privates58.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config8 mtu" not in line ] with open("/etc/privates58.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates58.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates59.sh"): with open("/etc/privates59.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config9 mtu" not in line ] with open("/etc/privates59.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates59.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates510.sh"): with open("/etc/privates510.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config10 mtu" not in line ] with open("/etc/privates510.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates510.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # mtu private 5 server iran 10 kharej def priv_kh1s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates21.sh"): with open("/etc/privates21.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config1 mtu" not in line ] with open("/etc/privates21.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates21.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates22.sh"): with open("/etc/privates22.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config2 mtu" not in line ] with open("/etc/privates22.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates22.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates23.sh"): with open("/etc/privates23.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config3 mtu" not in line ] with open("/etc/privates23.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates23.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates24.sh"): with open("/etc/privates24.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config4 mtu" not in line ] with open("/etc/privates24.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates24.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates25.sh"): with open("/etc/privates25.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config5 mtu" not in line ] with open("/etc/privates25.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates25.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates26.sh"): with open("/etc/privates26.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config6 mtu" not in line ] with open("/etc/privates26.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates26.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates27.sh"): with open("/etc/privates27.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config7 mtu" not in line ] with open("/etc/privates27.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates27.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates28.sh"): with open("/etc/privates28.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config8 mtu" not in line ] with open("/etc/privates28.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates28.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates29.sh"): with open("/etc/privates29.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config9 mtu" not in line ] with open("/etc/privates29.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates29.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10s2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran2config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates210.sh"): with open("/etc/privates210.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran2config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran2config10 mtu" not in line ] with open("/etc/privates210.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates210.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 3 def priv_kh1s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates31.sh"): with open("/etc/privates31.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config1 mtu" not in line ] with open("/etc/privates31.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates31.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates32.sh"): with open("/etc/privates32.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config2 mtu" not in line ] with open("/etc/privates32.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates32.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates33.sh"): with open("/etc/privates33.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config3 mtu" not in line ] with open("/etc/privates33.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates33.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates34.sh"): with open("/etc/privates34.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config4 mtu" not in line ] with open("/etc/privates34.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates34.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates35.sh"): with open("/etc/privates35.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config5 mtu" not in line ] with open("/etc/privates35.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates35.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates36.sh"): with open("/etc/privates36.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config6 mtu" not in line ] with open("/etc/privates36.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates36.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates37.sh"): with open("/etc/privates37.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config7 mtu" not in line ] with open("/etc/privates37.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates37.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates38.sh"): with open("/etc/privates38.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config8 mtu" not in line ] with open("/etc/privates38.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates38.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates39.sh"): with open("/etc/privates39.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config9 mtu" not in line ] with open("/etc/privates39.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates39.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10s3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran3config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates310.sh"): with open("/etc/privates310.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran3config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran3config10 mtu" not in line ] with open("/etc/privates310.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates310.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 4 def priv_kh1s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates41.sh"): with open("/etc/privates41.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config1 mtu" not in line ] with open("/etc/privates41.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates41.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates42.sh"): with open("/etc/privates42.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config2 mtu" not in line ] with open("/etc/privates42.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates42.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates43.sh"): with open("/etc/privates43.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config3 mtu" not in line ] with open("/etc/privates43.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates43.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates44.sh"): with open("/etc/privates44.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config4 mtu" not in line ] with open("/etc/privates44.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates44.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates45.sh"): with open("/etc/privates45.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config5 mtu" not in line ] with open("/etc/privates45.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates45.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates46.sh"): with open("/etc/privates46.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config6 mtu" not in line ] with open("/etc/privates46.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates46.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates47.sh"): with open("/etc/privates47.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config7 mtu" not in line ] with open("/etc/privates47.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates47.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates48.sh"): with open("/etc/privates48.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config8 mtu" not in line ] with open("/etc/privates48.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates48.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates49.sh"): with open("/etc/privates49.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config9 mtu" not in line ] with open("/etc/privates49.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates49.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10s4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran4config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates410.sh"): with open("/etc/privates410.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran4config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran4config10 mtu" not in line ] with open("/etc/privates410.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates410.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # server 5 def priv_kh1s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates51.sh"): with open("/etc/privates51.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config1 mtu" not in line ] with open("/etc/privates51.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates51.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates52.sh"): with open("/etc/privates52.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config2 mtu" not in line ] with open("/etc/privates52.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates52.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates53.sh"): with open("/etc/privates53.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config3 mtu" not in line ] with open("/etc/privates53.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates53.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates54.sh"): with open("/etc/privates54.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config4 mtu" not in line ] with open("/etc/privates54.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates54.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates55.sh"): with open("/etc/privates55.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config5 mtu" not in line ] with open("/etc/privates55.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates55.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates56.sh"): with open("/etc/privates56.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config6 mtu" not in line ] with open("/etc/privates56.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates56.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates57.sh"): with open("/etc/privates57.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config7 mtu" not in line ] with open("/etc/privates57.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates57.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates58.sh"): with open("/etc/privates58.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config8 mtu" not in line ] with open("/etc/privates58.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates58.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates59.sh"): with open("/etc/privates59.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config9 mtu" not in line ] with open("/etc/privates59.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates59.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10s5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran5config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates510.sh"): with open("/etc/privates510.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran5config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran5config10 mtu" not in line ] with open("/etc/privates510.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates510.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # edit server def edit_server2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit [10]KHAREJ [5]IRAN Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mAdd | Edit | Reconfig Server \033[0m") print( "2. \033[93mRemove [for reconfiging, first remove the appropriate server] \033[0m" ) print("0. \033[91mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editmenuu2() break elif server_type == "2": removemenuu3() break elif server_type == "0": clear() main_menu() break else: print("Invalid choice.") def editmenuu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mPRIVATE IP[SIT] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_5iran10kharej_private() break elif server_type == "0": clear() edit_server2() break else: print("Invalid choice.") # kharej side def edit_5iran10kharej_private(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - Configs\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mKHAREJ\033[0m") print("2. \033[92mIRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_private_editask() break elif server_type == "2": iran_private_editask() break elif server_type == "0": clear() editmenuu2() break else: print("Invalid choice.") def kharej_private_editask(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mKharej Server\033[93m? \033[96m(1-10)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Kharej server's number. Plz try again.\033[0m") return kharej_menu_name = "kharej_private_edit5iranmenu{}".format(iran_server_num) globals()[kharej_menu_name]() def iran_private_editask(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mIRAN Server\033[93m? \033[96m(1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Plz try again.\033[0m") return kharej_menu_name = "iran_private_edit5iranmenu{}".format(iran_server_num) globals()[kharej_menu_name]() def kharej_private_edit5iranmenu1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config1 \033[0m") print("2. \033[93m[2] Iran2config1 \033[0m") print("3. \033[93m[3] Iran3config1 \033[0m") print("4. \033[92m[4] Iran4config1 \033[0m") print("5. \033[93m[5] Iran5config1 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1s1_private_menu() break elif server_type == "2": kharej1s2_private_menu() break elif server_type == "3": kharej1s3_private_menu() break elif server_type == "4": kharej1s4_private_menu() break elif server_type == "5": kharej1s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config2 \033[0m") print("2. \033[93m[2] Iran2config2 \033[0m") print("3. \033[93m[3] Iran3config2 \033[0m") print("4. \033[92m[4] Iran4config2 \033[0m") print("5. \033[93m[5] Iran5config2 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej2s1_private_menu() break elif server_type == "2": kharej2s2_private_menu() break elif server_type == "3": kharej2s3_private_menu() break elif server_type == "4": kharej2s4_private_menu() break elif server_type == "5": kharej2s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config3 \033[0m") print("2. \033[93m[2] Iran2config3 \033[0m") print("3. \033[93m[3] Iran3config3 \033[0m") print("4. \033[92m[4] Iran4config3 \033[0m") print("5. \033[93m[5] Iran5config3 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej3s1_private_menu() break elif server_type == "2": kharej3s2_private_menu() break elif server_type == "3": kharej3s3_private_menu() break elif server_type == "4": kharej3s4_private_menu() break elif server_type == "5": kharej3s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config4 \033[0m") print("2. \033[93m[2] Iran2config4 \033[0m") print("3. \033[93m[3] Iran3config4 \033[0m") print("4. \033[92m[4] Iran4config4 \033[0m") print("5. \033[93m[5] Iran5config4 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej4s1_private_menu() break elif server_type == "2": kharej4s2_private_menu() break elif server_type == "3": kharej4s3_private_menu() break elif server_type == "4": kharej4s4_private_menu() break elif server_type == "5": kharej4s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config5 \033[0m") print("2. \033[93m[2] Iran2config5 \033[0m") print("3. \033[93m[3] Iran3config5 \033[0m") print("4. \033[92m[4] Iran4config5 \033[0m") print("5. \033[93m[5] Iran5config5 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5s1_private_menu() break elif server_type == "2": kharej5s2_private_menu() break elif server_type == "3": kharej5s3_private_menu() break elif server_type == "4": kharej5s4_private_menu() break elif server_type == "5": kharej5s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [6]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config6 \033[0m") print("2. \033[93m[2] Iran2config6 \033[0m") print("3. \033[93m[3] Iran3config6 \033[0m") print("4. \033[92m[4] Iran4config6 \033[0m") print("5. \033[93m[5] Iran5config6 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej6s1_private_menu() break elif server_type == "2": kharej6s2_private_menu() break elif server_type == "3": kharej6s3_private_menu() break elif server_type == "4": kharej6s4_private_menu() break elif server_type == "5": kharej6s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu7(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [7]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config7 \033[0m") print("2. \033[93m[2] Iran2config7 \033[0m") print("3. \033[93m[3] Iran3config7 \033[0m") print("4. \033[92m[4] Iran4config7 \033[0m") print("5. \033[93m[5] Iran5config7 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej7s1_private_menu() break elif server_type == "2": kharej7s2_private_menu() break elif server_type == "3": kharej7s3_private_menu() break elif server_type == "4": kharej7s4_private_menu() break elif server_type == "5": kharej7s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu8(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [8]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config8 \033[0m") print("2. \033[93m[2] Iran2config8 \033[0m") print("3. \033[93m[3] Iran3config8 \033[0m") print("4. \033[92m[4] Iran4config8 \033[0m") print("5. \033[93m[5] Iran5config8 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej8s1_private_menu() break elif server_type == "2": kharej8s2_private_menu() break elif server_type == "3": kharej8s3_private_menu() break elif server_type == "4": kharej8s4_private_menu() break elif server_type == "5": kharej8s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu9(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [9]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config9 \033[0m") print("2. \033[93m[2] Iran2config9 \033[0m") print("3. \033[93m[3] Iran3config9 \033[0m") print("4. \033[92m[4] Iran4config9 \033[0m") print("5. \033[93m[5] Iran5config9 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej9s1_private_menu() break elif server_type == "2": kharej9s2_private_menu() break elif server_type == "3": kharej9s3_private_menu() break elif server_type == "4": kharej9s4_private_menu() break elif server_type == "5": kharej9s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def kharej_private_edit5iranmenu10(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Private[SIT] Servers - \033[96mKharej [10]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what server & which config:\033[0m") print("1. \033[93m[1] Iran1config10 \033[0m") print("2. \033[93m[2] Iran2config10 \033[0m") print("3. \033[93m[3] Iran3config10 \033[0m") print("4. \033[92m[4] Iran4config10 \033[0m") print("5. \033[93m[5] Iran5config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej10s1_private_menu() break elif server_type == "2": kharej10s2_private_menu() break elif server_type == "3": kharej10s3_private_menu() break elif server_type == "4": kharej10s4_private_menu() break elif server_type == "5": kharej10s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def iran_private_edit5iranmenu1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Privateip Servers - \033[96mIRAN [1]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN SERVER [1]:\033[0m") print("1. \033[93mIran1config1 \033[0m") print("2. \033[93mIran1config2 \033[0m") print("3. \033[92mIran1config3 \033[0m") print("4. \033[93mIran1config4 \033[0m") print("5. \033[93mIran1config5 \033[0m") print("6. \033[93mIran1config6 \033[0m") print("7. \033[93mIran1config7 \033[0m") print("8. \033[92mIran1config8 \033[0m") print("9. \033[93mIran1config9 \033[0m") print("10.\033[93mIran1config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1s1_private_menu() break elif server_type == "2": iran2s1_private_menu() break elif server_type == "3": iran3s1_private_menu() break elif server_type == "4": iran4s1_private_menu() break elif server_type == "5": iran5s1_private_menu() break elif server_type == "6": iran6s1_private_menu() break elif server_type == "7": iran7s1_private_menu() break elif server_type == "8": iran8s1_private_menu() break elif server_type == "9": iran9s1_private_menu() break elif server_type == "10": iran10s1_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def iran_private_edit5iranmenu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Privateip Servers - \033[96mIRAN [2]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN SERVER [2]:\033[0m") print("1. \033[93mIran2config1 \033[0m") print("2. \033[93mIran2config2 \033[0m") print("3. \033[92mIran2config3 \033[0m") print("4. \033[93mIran2config4 \033[0m") print("5. \033[93mIran2config5 \033[0m") print("6. \033[93mIran2config6 \033[0m") print("7. \033[93mIran2config7 \033[0m") print("8. \033[92mIran2config8 \033[0m") print("9. \033[93mIran2config9 \033[0m") print("10.\033[93mIran2config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1s2_private_menu() break elif server_type == "2": iran2s2_private_menu() break elif server_type == "3": iran3s2_private_menu() break elif server_type == "4": iran4s2_private_menu() break elif server_type == "5": iran5s2_private_menu() break elif server_type == "6": iran6s2_private_menu() break elif server_type == "7": iran7s2_private_menu() break elif server_type == "8": iran8s2_private_menu() break elif server_type == "9": iran9s2_private_menu() break elif server_type == "10": iran10s2_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def iran_private_edit5iranmenu3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Privateip Servers - \033[96mIRAN [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN SERVER [3]:\033[0m") print("1. \033[93mIran3config1 \033[0m") print("2. \033[93mIran3config2 \033[0m") print("3. \033[92mIran3config3 \033[0m") print("4. \033[93mIran3config4 \033[0m") print("5. \033[93mIran3config5 \033[0m") print("6. \033[93mIran3config6 \033[0m") print("7. \033[93mIran3config7 \033[0m") print("8. \033[92mIran3config8 \033[0m") print("9. \033[93mIran3config9 \033[0m") print("10.\033[93mIran3config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1s3_private_menu() break elif server_type == "2": iran2s3_private_menu() break elif server_type == "3": iran3s3_private_menu() break elif server_type == "4": iran4s3_private_menu() break elif server_type == "5": iran5s3_private_menu() break elif server_type == "6": iran6s3_private_menu() break elif server_type == "7": iran7s3_private_menu() break elif server_type == "8": iran8s3_private_menu() break elif server_type == "9": iran9s3_private_menu() break elif server_type == "10": iran10s3_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def iran_private_edit5iranmenu4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Privateip Servers - \033[96mIRAN [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN SERVER [4]:\033[0m") print("1. \033[93mIran4config1 \033[0m") print("2. \033[93mIran4config2 \033[0m") print("3. \033[92mIran4config3 \033[0m") print("4. \033[93mIran4config4 \033[0m") print("5. \033[93mIran4config5 \033[0m") print("6. \033[93mIran4config6 \033[0m") print("7. \033[93mIran4config7 \033[0m") print("8. \033[92mIran4config8 \033[0m") print("9. \033[93mIran4config9 \033[0m") print("10.\033[93mIran4config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1s4_private_menu() break elif server_type == "2": iran2s4_private_menu() break elif server_type == "3": iran3s4_private_menu() break elif server_type == "4": iran4s4_private_menu() break elif server_type == "5": iran5s4_private_menu() break elif server_type == "6": iran6s4_private_menu() break elif server_type == "7": iran7s4_private_menu() break elif server_type == "8": iran8s4_private_menu() break elif server_type == "9": iran9s4_private_menu() break elif server_type == "10": iran10s4_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") def iran_private_edit5iranmenu5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Privateip Servers - \033[96mIRAN [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m═══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN SERVER [5]:\033[0m") print("1. \033[93mIran5config1 \033[0m") print("2. \033[93mIran5config2 \033[0m") print("3. \033[92mIran5config3 \033[0m") print("4. \033[93mIran5config4 \033[0m") print("5. \033[93mIran5config5 \033[0m") print("6. \033[93mIran5config6 \033[0m") print("7. \033[93mIran5config7 \033[0m") print("8. \033[92mIran5config8 \033[0m") print("9. \033[93mIran5config9 \033[0m") print("10.\033[93mIran5config10 \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1s5_private_menu() break elif server_type == "2": iran2s5_private_menu() break elif server_type == "3": iran3s5_private_menu() break elif server_type == "4": iran4s5_private_menu() break elif server_type == "5": iran5s5_private_menu() break elif server_type == "6": iran6s5_private_menu() break elif server_type == "7": iran7s5_private_menu() break elif server_type == "8": iran8s5_private_menu() break elif server_type == "9": iran9s5_private_menu() break elif server_type == "10": iran10s5_private_menu() break elif server_type == "0": clear() edit_5iran10kharej_private() break else: print("Invalid choice.") # mtu def mtu3_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mEdit MTU [10]KHAREJ [5]IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mPRIVATE [SIT]\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private5iran_mtumnu() break elif server_type == "0": clear() main_menu() break else: print("Invalid choice.") def private5iran_mtumnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mEdit MTU [10]KHAREJ [5]IRAN Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private5iran_mnum1() break elif server_type == "2": private5iran_mnum2() break elif server_type == "0": clear() mtu3_menu() break else: print("Invalid choice.") def private5iran_mnum1(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mKharej Server\033[93m? \033[96m(1-10)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 10: print("\033[91mWrong Kharej server's number. Plz try again.\033[0m") return kharej_menu_name = "private5iran_mnu{}".format(iran_server_num) globals()[kharej_menu_name]() def private5iran_mnum2(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mIRAN Server\033[93m? \033[96m(1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Plz try again.\033[0m") return kharej_menu_name = "mtu1_qserver{}".format(iran_server_num) globals()[kharej_menu_name]() # iran side def mtu1_qserver1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m IRAN[1] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN [1]:\033[0m") print("1. \033[92mIran1config1\033[0m") print("2. \033[93mIran1config2\033[0m") print("3. \033[93mIran1config3\033[0m") print("4. \033[92mIran1config4\033[0m") print("5. \033[92mIran1config5\033[0m") print("6. \033[92mIran1config6\033[0m") print("7. \033[93mIran1config7\033[0m") print("8. \033[93mIran1config8\033[0m") print("9. \033[92mIran1config9\033[0m") print("10.\033[92mIran1config10\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1s1_mtu() break elif server_type == "2": priv_ir2s1_mtu() break elif server_type == "3": priv_ir3s1_mtu() break elif server_type == "4": priv_ir4s1_mtu() break elif server_type == "5": priv_ir5s1_mtu() break elif server_type == "6": priv_ir6s1_mtu() break elif server_type == "7": priv_ir7s1_mtu() break elif server_type == "8": priv_ir8s1_mtu() break elif server_type == "9": priv_ir9s1_mtu() break elif server_type == "10": priv_ir10s1_mtu() break elif server_type == "11": priv_irall_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_irall_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}s1_mtu".format(i) globals()[menu_name]() def mtu1_qserver2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m IRAN[2] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN [2]:\033[0m") print("1. \033[92mIran2config1\033[0m") print("2. \033[93mIran2config2\033[0m") print("3. \033[93mIran2config3\033[0m") print("4. \033[92mIran2config4\033[0m") print("5. \033[92mIran2config5\033[0m") print("6. \033[92mIran2config6\033[0m") print("7. \033[93mIran2config7\033[0m") print("8. \033[93mIran2config8\033[0m") print("9. \033[92mIran2config9\033[0m") print("10.\033[92mIran2config10\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1s2_mtu() break elif server_type == "2": priv_ir2s2_mtu() break elif server_type == "3": priv_ir3s2_mtu() break elif server_type == "4": priv_ir4s2_mtu() break elif server_type == "5": priv_ir5s2_mtu() break elif server_type == "6": priv_ir6s2_mtu() break elif server_type == "7": priv_ir7s2_mtu() break elif server_type == "8": priv_ir8s2_mtu() break elif server_type == "9": priv_ir9s2_mtu() break elif server_type == "10": priv_ir10s2_mtu() break elif server_type == "11": priv_irall2_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_irall2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}s2_mtu".format(i) globals()[menu_name]() def mtu1_qserver3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m IRAN[3] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN [3]:\033[0m") print("1. \033[92mIran3config1\033[0m") print("2. \033[93mIran3config2\033[0m") print("3. \033[93mIran3config3\033[0m") print("4. \033[92mIran3config4\033[0m") print("5. \033[92mIran3config5\033[0m") print("6. \033[92mIran3config6\033[0m") print("7. \033[93mIran3config7\033[0m") print("8. \033[93mIran3config8\033[0m") print("9. \033[92mIran3config9\033[0m") print("10.\033[92mIran3config10\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1s3_mtu() break elif server_type == "2": priv_ir2s3_mtu() break elif server_type == "3": priv_ir3s3_mtu() break elif server_type == "4": priv_ir4s3_mtu() break elif server_type == "5": priv_ir5s3_mtu() break elif server_type == "6": priv_ir6s3_mtu() break elif server_type == "7": priv_ir7s3_mtu() break elif server_type == "8": priv_ir8s3_mtu() break elif server_type == "9": priv_ir9s3_mtu() break elif server_type == "10": priv_ir10s3_mtu() break elif server_type == "11": priv_irall3_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_irall3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}s3_mtu".format(i) globals()[menu_name]() def mtu1_qserver4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m IRAN[4] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN [4]:\033[0m") print("1. \033[92mIran4config1\033[0m") print("2. \033[93mIran4config2\033[0m") print("3. \033[93mIran4config3\033[0m") print("4. \033[92mIran4config4\033[0m") print("5. \033[92mIran4config5\033[0m") print("6. \033[92mIran4config6\033[0m") print("7. \033[93mIran4config7\033[0m") print("8. \033[93mIran4config8\033[0m") print("9. \033[92mIran4config9\033[0m") print("10.\033[92mIran4config10\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1s4_mtu() break elif server_type == "2": priv_ir2s4_mtu() break elif server_type == "3": priv_ir3s4_mtu() break elif server_type == "4": priv_ir4s4_mtu() break elif server_type == "5": priv_ir5s4_mtu() break elif server_type == "6": priv_ir6s4_mtu() break elif server_type == "7": priv_ir7s4_mtu() break elif server_type == "8": priv_ir8s4_mtu() break elif server_type == "9": priv_ir9s4_mtu() break elif server_type == "10": priv_ir10s4_mtu() break elif server_type == "11": priv_irall4_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_irall4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}s4_mtu".format(i) globals()[menu_name]() def mtu1_qserver5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m IRAN[5] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is IRAN [5]:\033[0m") print("1. \033[92mIran5config1\033[0m") print("2. \033[93mIran5config2\033[0m") print("3. \033[93mIran5config3\033[0m") print("4. \033[92mIran5config4\033[0m") print("5. \033[92mIran5config5\033[0m") print("6. \033[92mIran5config6\033[0m") print("7. \033[93mIran5config7\033[0m") print("8. \033[93mIran5config8\033[0m") print("9. \033[92mIran5config9\033[0m") print("10.\033[92mIran5config10\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1s5_mtu() break elif server_type == "2": priv_ir2s5_mtu() break elif server_type == "3": priv_ir3s5_mtu() break elif server_type == "4": priv_ir4s5_mtu() break elif server_type == "5": priv_ir5s5_mtu() break elif server_type == "6": priv_ir6s5_mtu() break elif server_type == "7": priv_ir7s5_mtu() break elif server_type == "8": priv_ir8s5_mtu() break elif server_type == "9": priv_ir9s5_mtu() break elif server_type == "10": priv_ir10s5_mtu() break elif server_type == "11": priv_irall5_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_irall5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}s5_mtu".format(i) globals()[menu_name]() # server 1 kharej def private5iran_mnu1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[1] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [1]:\033[0m") print("1. \033[92mIran1config1\033[0m") print("2. \033[93mIran2config1\033[0m") print("3. \033[93mIran3config1\033[0m") print("4. \033[92mIran4config1\033[0m") print("5. \033[92mIran5config1\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh1s1_mtu() break elif server_type == "2": priv_kh1s2_mtu() break elif server_type == "3": priv_kh1s3_mtu() break elif server_type == "4": priv_kh1s4_mtu() break elif server_type == "5": priv_kh1s5_mtu() break elif server_type == "6": priv_khall_mtu() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh1s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[2] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [2]:\033[0m") print("1. \033[92mIran1config2\033[0m") print("2. \033[93mIran2config2\033[0m") print("3. \033[93mIran3config2\033[0m") print("4. \033[92mIran4config2\033[0m") print("5. \033[92mIran5config2\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh2s1_mtu() break elif server_type == "2": priv_kh2s2_mtu() break elif server_type == "3": priv_kh2s3_mtu() break elif server_type == "4": priv_kh2s4_mtu() break elif server_type == "5": priv_kh2s5_mtu() break elif server_type == "6": priv_khall_mtu2() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh2s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[3] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [3]:\033[0m") print("1. \033[92mIran1config3\033[0m") print("2. \033[93mIran2config3\033[0m") print("3. \033[93mIran3config3\033[0m") print("4. \033[92mIran4config3\033[0m") print("5. \033[92mIran5config3\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh3s1_mtu() break elif server_type == "2": priv_kh3s2_mtu() break elif server_type == "3": priv_kh3s3_mtu() break elif server_type == "4": priv_kh3s4_mtu() break elif server_type == "5": priv_kh3s5_mtu() break elif server_type == "6": priv_khall_mtu3() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh3s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[4] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [4]:\033[0m") print("1. \033[92mIran1config4\033[0m") print("2. \033[93mIran2config4\033[0m") print("3. \033[93mIran3config4\033[0m") print("4. \033[92mIran4config4\033[0m") print("5. \033[92mIran5config4\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh4s1_mtu() break elif server_type == "2": priv_kh4s2_mtu() break elif server_type == "3": priv_kh4s3_mtu() break elif server_type == "4": priv_kh4s4_mtu() break elif server_type == "5": priv_kh4s5_mtu() break elif server_type == "6": priv_khall_mtu4() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh4s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[5] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [5]:\033[0m") print("1. \033[92mIran1config5\033[0m") print("2. \033[93mIran2config5\033[0m") print("3. \033[93mIran3config5\033[0m") print("4. \033[92mIran4config5\033[0m") print("5. \033[92mIran5config5\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh5s1_mtu() break elif server_type == "2": priv_kh5s2_mtu() break elif server_type == "3": priv_kh5s3_mtu() break elif server_type == "4": priv_kh5s4_mtu() break elif server_type == "5": priv_kh5s5_mtu() break elif server_type == "6": priv_khall_mtu5() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh5s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[6] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [6]:\033[0m") print("1. \033[92mIran1config6\033[0m") print("2. \033[93mIran2config6\033[0m") print("3. \033[93mIran3config6\033[0m") print("4. \033[92mIran4config6\033[0m") print("5. \033[92mIran5config6\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh6s1_mtu() break elif server_type == "2": priv_kh6s2_mtu() break elif server_type == "3": priv_kh6s3_mtu() break elif server_type == "4": priv_kh6s4_mtu() break elif server_type == "5": priv_kh6s5_mtu() break elif server_type == "6": priv_khall_mtu6() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu6(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh6s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu7(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[7] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [7]:\033[0m") print("1. \033[92mIran1config7\033[0m") print("2. \033[93mIran2config7\033[0m") print("3. \033[93mIran3config7\033[0m") print("4. \033[92mIran4config7\033[0m") print("5. \033[92mIran5config7\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh7s1_mtu() break elif server_type == "2": priv_kh7s2_mtu() break elif server_type == "3": priv_kh7s3_mtu() break elif server_type == "4": priv_kh7s4_mtu() break elif server_type == "5": priv_kh7s5_mtu() break elif server_type == "6": priv_khall_mtu7() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu7(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh7s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu8(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[8] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [8]:\033[0m") print("1. \033[92mIran1config8\033[0m") print("2. \033[93mIran2config8\033[0m") print("3. \033[93mIran3config8\033[0m") print("4. \033[92mIran4config8\033[0m") print("5. \033[92mIran5config8\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh8s1_mtu() break elif server_type == "2": priv_kh8s2_mtu() break elif server_type == "3": priv_kh8s3_mtu() break elif server_type == "4": priv_kh8s4_mtu() break elif server_type == "5": priv_kh8s5_mtu() break elif server_type == "6": priv_khall_mtu8() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu8(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh8s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu9(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[9] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [9]:\033[0m") print("1. \033[92mIran1config9\033[0m") print("2. \033[93mIran2config9\033[0m") print("3. \033[93mIran3config9\033[0m") print("4. \033[92mIran4config9\033[0m") print("5. \033[92mIran5config9\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh9s1_mtu() break elif server_type == "2": priv_kh9s2_mtu() break elif server_type == "3": priv_kh9s3_mtu() break elif server_type == "4": priv_kh9s4_mtu() break elif server_type == "5": priv_kh9s5_mtu() break elif server_type == "6": priv_khall_mtu9() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu9(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh9s{}_mtu".format(i) globals()[menu_name]() def private5iran_mnu10(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]Kharej[5]IRAN-\033[96m Kharej[10] \033[93mEdit Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mThis is KHAREJ [10]:\033[0m") print("1. \033[92mIran1config10\033[0m") print("2. \033[93mIran2config10\033[0m") print("3. \033[93mIran3config10\033[0m") print("4. \033[92mIran4config10\033[0m") print("5. \033[92mIran5config10\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh10s1_mtu() break elif server_type == "2": priv_kh10s2_mtu() break elif server_type == "3": priv_kh10s3_mtu() break elif server_type == "4": priv_kh10s4_mtu() break elif server_type == "5": priv_kh10s5_mtu() break elif server_type == "6": priv_khall_mtu10() break elif server_type == "0": clear() private5iran_mtumnu() break else: print("Invalid choice.") def priv_khall_mtu10(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIran Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh10s{}_mtu".format(i) globals()[menu_name]() # uninstall server 2 def removemenuu3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m[10]Kharej [5]IRAN Multiple Servers Menu\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mUninstall Private IP\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_priv_5iran10kharej() break elif server_type == "0": clear() edit_server2() break else: print("Invalid choice.") def remove_priv_5iran10kharej(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m[10]Kharej [5]IRAN Multiple Servers Menu\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mWhich server to remove:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": rmv_edit_kharejprivate() break elif server_type == "2": rmv_edit_iranprivate() break elif server_type == "0": clear() removemenuu3() break else: print("Invalid choice.") def rmv_edit_kharejprivate(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Remove list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mKharej Server\033[93m? \033[96m(1-10)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 10: print("\033[91mWrong Kharej server's number. Plz try again.\033[0m") return kharej_menu_name = "rmv_5iran10kharej_private{}".format(iran_server_num) globals()[kharej_menu_name]() def rmv_edit_iranprivate(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Remove list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mIRAN Server\033[93m? \033[96m(1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Plz try again.\033[0m") return kharej_menu_name = "edit_5iran10kharej_6to4{}".format(iran_server_num) globals()[kharej_menu_name]() def rmv_5iran10kharej_private1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[1]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIran1config1\033[0m") print("2. \033[92mIran2config1\033[0m") print("3. \033[93mIran3config1\033[0m") print("4. \033[92mIran4config1\033[0m") print("5. \033[92mIran5config1\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s1() break elif server_type == "2": remove_private1s2() break elif server_type == "3": remove_private1s3() break elif server_type == "4": remove_private1s4() break elif server_type == "5": remove_private1s5() break elif server_type == "6": ip6_5iran_qprivate() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private1s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[2]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIran1config2\033[0m") print("2. \033[92mIran2config2\033[0m") print("3. \033[93mIran3config2\033[0m") print("4. \033[92mIran4config2\033[0m") print("5. \033[92mIran5config2\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private2s1() break elif server_type == "2": remove_private2s2() break elif server_type == "3": remove_private2s3() break elif server_type == "4": remove_private2s4() break elif server_type == "5": remove_private2s5() break elif server_type == "6": ip6_5iran_qprivate2() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private2s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[3]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config3\033[0m") print("2. \033[92mIran2config3\033[0m") print("3. \033[93mIran3config3\033[0m") print("4. \033[92mIran4config3\033[0m") print("5. \033[92mIran5config3\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private3s1() break elif server_type == "2": remove_private3s2() break elif server_type == "3": remove_private3s3() break elif server_type == "4": remove_private3s4() break elif server_type == "5": remove_private3s5() break elif server_type == "6": ip6_5iran_qprivate3() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private3s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[4]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config4\033[0m") print("2. \033[92mIran2config4\033[0m") print("3. \033[93mIran3config4\033[0m") print("4. \033[92mIran4config4\033[0m") print("5. \033[92mIran5config4\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private4s1() break elif server_type == "2": remove_private4s2() break elif server_type == "3": remove_private4s3() break elif server_type == "4": remove_private4s4() break elif server_type == "5": remove_private4s5() break elif server_type == "6": ip6_5iran_qprivate4() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private4s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[5]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config5\033[0m") print("2. \033[92mIran2config5\033[0m") print("3. \033[93mIran3config5\033[0m") print("4. \033[92mIran4config5\033[0m") print("5. \033[92mIran5config5\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private5s1() break elif server_type == "2": remove_private5s2() break elif server_type == "3": remove_private5s3() break elif server_type == "4": remove_private5s4() break elif server_type == "5": remove_private5s5() break elif server_type == "6": ip6_5iran_qprivate5() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private5s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[6]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config6\033[0m") print("2. \033[92mIran2config6\033[0m") print("3. \033[93mIran3config6\033[0m") print("4. \033[92mIran4config6\033[0m") print("5. \033[92mIran5config6\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private6s1() break elif server_type == "2": remove_private6s2() break elif server_type == "3": remove_private6s3() break elif server_type == "4": remove_private6s4() break elif server_type == "5": remove_private6s5() break elif server_type == "6": ip6_5iran_qprivate6() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate6(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private6s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private7(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[7]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config7\033[0m") print("2. \033[92mIran2config7\033[0m") print("3. \033[93mIran3config7\033[0m") print("4. \033[92mIran4config7\033[0m") print("5. \033[92mIran5config7\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private7s1() break elif server_type == "2": remove_private7s2() break elif server_type == "3": remove_private7s3() break elif server_type == "4": remove_private7s4() break elif server_type == "5": remove_private7s5() break elif server_type == "6": ip6_5iran_qprivate7() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate7(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private7s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private8(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[8]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config8\033[0m") print("2. \033[92mIran2config8\033[0m") print("3. \033[93mIran3config8\033[0m") print("4. \033[92mIran4config8\033[0m") print("5. \033[92mIran5config8\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private8s1() break elif server_type == "2": remove_private8s2() break elif server_type == "3": remove_private8s3() break elif server_type == "4": remove_private8s4() break elif server_type == "5": remove_private8s5() break elif server_type == "6": ip6_5iran_qprivate8() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate8(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private8s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private9(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[9]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config9\033[0m") print("2. \033[92mIran2config9\033[0m") print("3. \033[93mIran3config9\033[0m") print("4. \033[92mIran4config9\033[0m") print("5. \033[92mIran5config9\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private9s1() break elif server_type == "2": remove_private9s2() break elif server_type == "3": remove_private9s3() break elif server_type == "4": remove_private9s4() break elif server_type == "5": remove_private9s5() break elif server_type == "6": ip6_5iran_qprivate9() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate9(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private9s{}".format(i) globals()[menu_name]() def rmv_5iran10kharej_private10(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip [10]Kharej [5]IRAN - \033[96mKharej[10]\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose:\033[0m") print("1. \033[92mIran1config10\033[0m") print("2. \033[92mIran2config10\033[0m") print("3. \033[93mIran3config10\033[0m") print("4. \033[92mIran4config10\033[0m") print("5. \033[92mIran5config10\033[0m") print("6. \033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private10s1() break elif server_type == "2": remove_private10s2() break elif server_type == "3": remove_private10s3() break elif server_type == "4": remove_private10s4() break elif server_type == "5": remove_private10s5() break elif server_type == "6": ip6_5iran_qprivate10() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_5iran_qprivate10(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private10s{}".format(i) globals()[menu_name]() # iran def edit_5iran10kharej_6to41(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip \033[96mIRAN Server [1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose :\033[0m") print("1. \033[92mIran1config1\033[0m") print("2. \033[92mIran2config1\033[0m") print("3. \033[93mIran3config1\033[0m") print("4. \033[92mIran4config1\033[0m") print("5. \033[92mIran5config1\033[0m") print("6. \033[92mIran6config1\033[0m") print("7. \033[92mIran7config1\033[0m") print("8. \033[93mIran8config1\033[0m") print("9. \033[92mIran9config1\033[0m") print("10.\033[92mIran10config1\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s1i() break elif server_type == "2": remove_private2s1i() break elif server_type == "3": remove_private3s1i() break elif server_type == "4": remove_private4s1i() break elif server_type == "5": remove_private5s1i() break elif server_type == "6": remove_private6s1i() break elif server_type == "7": remove_private7s1i() break elif server_type == "8": remove_private8s1i() break elif server_type == "9": remove_private9s1i() break elif server_type == "10": remove_private10s1i() break elif server_type == "11": ip6_10iran_qprivate1() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_10iran_qprivate1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s1i".format(i) globals()[menu_name]() def edit_5iran10kharej_6to42(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip \033[96mIRAN Server [2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose :\033[0m") print("1. \033[92mIran1config2\033[0m") print("2. \033[92mIran2config2\033[0m") print("3. \033[93mIran3config2\033[0m") print("4. \033[92mIran4config2\033[0m") print("5. \033[92mIran5config2\033[0m") print("6. \033[92mIran6config2\033[0m") print("7. \033[92mIran7config2\033[0m") print("8. \033[93mIran8config2\033[0m") print("9. \033[92mIran9config2\033[0m") print("10.\033[92mIran10config2\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s2i() break elif server_type == "2": remove_private2s2i() break elif server_type == "3": remove_private3s2i() break elif server_type == "4": remove_private4s2i() break elif server_type == "5": remove_private5s2i() break elif server_type == "6": remove_private6s2i() break elif server_type == "7": remove_private7s2i() break elif server_type == "8": remove_private8s2i() break elif server_type == "9": remove_private9s2i() break elif server_type == "10": remove_private10s2i() break elif server_type == "11": ip6_10iran_qprivate2() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_10iran_qprivate2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s2i".format(i) globals()[menu_name]() def edit_5iran10kharej_6to43(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip \033[96mIRAN Server [3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose :\033[0m") print("1. \033[92mIran1config3\033[0m") print("2. \033[92mIran2config3\033[0m") print("3. \033[93mIran3config3\033[0m") print("4. \033[92mIran4config3\033[0m") print("5. \033[92mIran5config3\033[0m") print("6. \033[92mIran6config3\033[0m") print("7. \033[92mIran7config3\033[0m") print("8. \033[93mIran8config3\033[0m") print("9. \033[92mIran9config3\033[0m") print("10.\033[92mIran10config3\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s3i() break elif server_type == "2": remove_private2s3i() break elif server_type == "3": remove_private3s3i() break elif server_type == "4": remove_private4s3i() break elif server_type == "5": remove_private5s3i() break elif server_type == "6": remove_private6s3i() break elif server_type == "7": remove_private7s3i() break elif server_type == "8": remove_private8s3i() break elif server_type == "9": remove_private9s3i() break elif server_type == "10": remove_private10s3i() break elif server_type == "11": ip6_10iran_qprivate3() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_10iran_qprivate3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s3i".format(i) globals()[menu_name]() def edit_5iran10kharej_6to44(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip \033[96mIRAN Server [4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose :\033[0m") print("1. \033[92mIran1config4\033[0m") print("2. \033[92mIran2config4\033[0m") print("3. \033[93mIran3config4\033[0m") print("4. \033[92mIran4config4\033[0m") print("5. \033[92mIran5config4\033[0m") print("6. \033[92mIran6config4\033[0m") print("7. \033[92mIran7config4\033[0m") print("8. \033[93mIran8config4\033[0m") print("9. \033[92mIran9config4\033[0m") print("10.\033[92mIran10config4\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s4i() break elif server_type == "2": remove_private2s4i() break elif server_type == "3": remove_private3s4i() break elif server_type == "4": remove_private4s4i() break elif server_type == "5": remove_private5s4i() break elif server_type == "6": remove_private6s4i() break elif server_type == "7": remove_private7s4i() break elif server_type == "8": remove_private8s4i() break elif server_type == "9": remove_private9s4i() break elif server_type == "10": remove_private10s4i() break elif server_type == "11": ip6_10iran_qprivate4() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_10iran_qprivate4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s4i".format(i) globals()[menu_name]() def edit_5iran10kharej_6to45(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Privateip \033[96mIRAN Server [5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose :\033[0m") print("1. \033[92mIran1config5\033[0m") print("2. \033[92mIran2config5\033[0m") print("3. \033[93mIran3config5\033[0m") print("4. \033[92mIran4config5\033[0m") print("5. \033[92mIran5config5\033[0m") print("6. \033[92mIran6config5\033[0m") print("7. \033[92mIran7config5\033[0m") print("8. \033[93mIran8config5\033[0m") print("9. \033[92mIran9config5\033[0m") print("10.\033[92mIran10config5\033[0m") print("11.\033[96mAll of them\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s5i() break elif server_type == "2": remove_private2s5i() break elif server_type == "3": remove_private3s5i() break elif server_type == "4": remove_private4s5i() break elif server_type == "5": remove_private5s5i() break elif server_type == "6": remove_private6s5i() break elif server_type == "7": remove_private7s5i() break elif server_type == "8": remove_private8s5i() break elif server_type == "9": remove_private9s5i() break elif server_type == "10": remove_private10s5i() break elif server_type == "11": ip6_10iran_qprivate5() break elif server_type == "0": clear() remove_priv_5iran10kharej() break else: print("Invalid choice.") def ip6_10iran_qprivate5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mConfigs\033[93m do you want to delete?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s5i".format(i) globals()[menu_name]() # uninstall def remove3_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m[10]KHAREJ [5]IRAN Multiple Servers Menu\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mUninstall PrivateIP [SIT]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove3_menu_privateip() break elif server_type == "0": clear() multi2server_mnu() break else: print("Invalid choice.") def remove3_menu_privateip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m[10]Kharej [5]IRAN Multiple Servers Menu\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mWhich server to remove:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": rmv_edit_kharejprivate() break elif server_type == "2": rmv_edit_iranprivate() break elif server_type == "0": clear() remove3_menu() break else: print("Invalid choice.") def rmv5_qtenkharej_private1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private1s{}".format(i) globals()[menu_name]() def rmv_tenonekharejiran_private1m(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Remove list\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mChoose \033[92mKharej Server\033[93m? \033[96m(1-10)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 10: print("\033[91mWrong Iran server's number. Plz try again.\033[0m") return kharej_menu_name = "rmv_5iran10kharej_private{}".format(iran_server_num) globals()[kharej_menu_name]() def rmv_tenonekharejiran_private1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN [1] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s1() break elif server_type == "2": remove_private2s1() break elif server_type == "3": remove_private3s1() break elif server_type == "4": remove_private4s1() break elif server_type == "5": remove_private5s1() break elif server_type == "6": remove_private6s1() break elif server_type == "7": remove_private7s1() break elif server_type == "8": remove_private8s1() break elif server_type == "9": remove_private9s1() break elif server_type == "10": remove_private10s1() break elif server_type == "11": rmv5_qtenkharej_private1() break elif server_type == "0": clear() remove3_menu_privateip() break else: print("Invalid choice.") # server2 def rmv5_qtenkharej_private2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s2i".format(i) globals()[menu_name]() def rmv_tenonekharejiran_private2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN [2] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s2() break elif server_type == "2": remove_private2s2() break elif server_type == "3": remove_private3s2() break elif server_type == "4": remove_private4s2() break elif server_type == "5": remove_private5s2() break elif server_type == "6": remove_private6s2() break elif server_type == "7": remove_private7s2() break elif server_type == "8": remove_private8s2() break elif server_type == "9": remove_private9s2() break elif server_type == "10": remove_private10s2() break elif server_type == "11": rmv5_qtenkharej_private2() break elif server_type == "0": clear() remove3_menu_privateip() break else: print("Invalid choice.") # server3 def rmv5_qtenkharej_private3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s3i".format(i) globals()[menu_name]() def rmv_tenonekharejiran_private3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN [3] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s3() break elif server_type == "2": remove_private2s3() break elif server_type == "3": remove_private3s3() break elif server_type == "4": remove_private4s3() break elif server_type == "5": remove_private5s3() break elif server_type == "6": remove_private6s3() break elif server_type == "7": remove_private7s3() break elif server_type == "8": remove_private8s3() break elif server_type == "9": remove_private9s3() break elif server_type == "10": remove_private10s3() break elif server_type == "11": rmv5_qtenkharej_private3() break elif server_type == "0": clear() remove3_menu_privateip() break else: print("Invalid choice.") # server 4 def rmv5_qtenkharej_private4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s4i".format(i) globals()[menu_name]() def rmv_tenonekharejiran_private4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN [4] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s4() break elif server_type == "2": remove_private2s4() break elif server_type == "3": remove_private3s4() break elif server_type == "4": remove_private4s4() break elif server_type == "5": remove_private5s4() break elif server_type == "6": remove_private6s4() break elif server_type == "7": remove_private7s4() break elif server_type == "8": remove_private8s4() break elif server_type == "9": remove_private9s4() break elif server_type == "10": remove_private10s4() break elif server_type == "11": rmv5_qtenkharej_private4() break elif server_type == "0": clear() remove3_menu_privateip() break else: print("Invalid choice.") # server5 def rmv5_qtenkharej_private5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "remove_private{}s5i".format(i) globals()[menu_name]() def rmv_tenonekharejiran_private5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Private [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[93mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[93mKharej[7]\033[0m") print("8. \033[92mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1s5() break elif server_type == "2": remove_private2s5() break elif server_type == "3": remove_private3s5() break elif server_type == "4": remove_private4s5() break elif server_type == "5": remove_private5s5() break elif server_type == "6": remove_private6s5() break elif server_type == "7": remove_private7s5() break elif server_type == "8": remove_private8s5() break elif server_type == "9": remove_private9s5() break elif server_type == "10": remove_private10s5() break elif server_type == "11": rmv5_qtenkharej_private5() break elif server_type == "0": clear() remove3_menu_privateip() break else: print("Invalid choice.") # 5iran 10 kharej def iran5_kharej10_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m[10]KHAREJ [5]IRAN \033[92m Multiple Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("0 \033[92mTunnel Names Guide \033[97mMENU\033[0m") print("1. \033[93mPrivate IP [SIT]\033[0m") print("2. \033[96mEdit MTU\033[0m") print("3. \033[93mEdit Servers\033[0m") print("4. \033[91mUninstall\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": name2_mnu() break elif choice == "1": priviran5_mnu_ipnew() break elif choice == "2": mtu3_menu() break elif choice == "3": edit_server2() break elif choice == "4": remove3_menu() break elif server_type == "0": os.system("clear") multi2server_mnu() break else: print("Invalid choice.") def priviran5_mnu_ipnew(): while True: os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config lists\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[97mIRAN SERVERS\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_private_menu_selection() break elif server_type == "2": kharej2_private_menu_selection() break elif server_type == "3": kharej3_private_menu_selection() break elif server_type == "4": kharej4_private_menu_selection() break elif server_type == "5": kharej5_private_menu_selection() break elif server_type == "6": kharej6_private_menu_selection() break elif server_type == "7": kharej7_private_menu_selection() break elif server_type == "8": kharej8_private_menu_selection() break elif server_type == "9": kharej9_private_menu_selection() break elif server_type == "10": kharej10_private_menu_selection() break elif server_type == "11": iran_private_menu_selection() break elif server_type == "0": os.system("clear") iran5_kharej10_mnu() break else: print("Invalid choice.") def kharej1_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej1s{}_private_menu".format(i) globals()[menu_name]() def kharej2_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej2s{}_private_menu".format(i) globals()[menu_name]() def kharej3_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej3s{}_private_menu".format(i) globals()[menu_name]() def kharej4_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej4s{}_private_menu".format(i) globals()[menu_name]() def kharej5_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej5s{}_private_menu".format(i) globals()[menu_name]() def kharej6_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej6s{}_private_menu".format(i) globals()[menu_name]() def kharej7_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej7s{}_private_menu".format(i) globals()[menu_name]() def kharej8_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej8s{}_private_menu".format(i) globals()[menu_name]() def kharej9_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej9s{}_private_menu".format(i) globals()[menu_name]() def kharej10_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[96m (1-5)\033[93m: \033[0m" ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server's number. Please try again.\033[0m") return for i in range(1, iran_server_num + 1): menu_name = "kharej10s{}_private_menu".format(i) globals()[menu_name]() def iran_private_menu_selection(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10] Kharej [5] IRAN - Config list[1] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") iran_server_num = int( input( "\033[93mWhich \033[92mIRAN Server\033[93m are you configuring right now? \033[96m(1-5)\033[93m: \033[0m" ) ) num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[96m(1-10)\033[0m " ) ) if iran_server_num < 1 or iran_server_num > 5: print("\033[91mWrong Iran server number. Please try again.\033[0m") return if num_servers < 1 or num_servers > 10: print("\033[91mWrong number of Kharej servers. Please try again.\033[0m") return for i in range(1, num_servers + 1): menu_name = "iran{}s{}_private_menu".format(i, iran_server_num) globals()[menu_name]() ## Kharej 1 servre 2 def adds2_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates21.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates21.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:701b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v61.service"]) subprocess.run(["systemctl", "start", "pings2_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v61.service"]) def kharej1s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/privates21.sh"): os.remove("/etc/privates21.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:701b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:701b::2/64", "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates21.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config1 up\n") f.write("ip addr add 2002:701b::1/64 dev iran2config1\n") f.write("ip -6 route add 2002:701b::2/64 dev iran2config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config1 mtu {mtu_value}\n" with open("/etc/privates21.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:701b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v61.sh", 0o755) pings2_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 server 2 def adds2_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates22.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates22.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:711b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v62.service"]) subprocess.run(["systemctl", "start", "pings2_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v62.service"]) def pings1_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v62.service"]) subprocess.run(["systemctl", "start", "pings1_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v62.service"]) def kharej2s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/privates22.sh"): os.remove("/etc/privates22.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:711b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:711b::2/64", "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates22.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config2 up\n") f.write("ip addr add 2002:711b::1/64 dev iran2config2\n") f.write("ip -6 route add 2002:711b::2/64 dev iran2config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config2 mtu {mtu_value}\n" with open("/etc/privates22.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:711b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v62.sh", 0o755) pings2_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 server 2 def adds2_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates23.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates23.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:721b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v63.service"]) subprocess.run(["systemctl", "start", "pings2_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v63.service"]) def kharej3s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/privates23.sh"): os.remove("/etc/privates23.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:721b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:721b::2/64", "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates23.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config3 up\n") f.write("ip addr add 2002:721b::1/64 dev iran2config3\n") f.write("ip -6 route add 2002:721b::2/64 dev iran2config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config3 mtu {mtu_value}\n" with open("/etc/privates23.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:721b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v63.sh", 0o755) pings2_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 server 2 def adds2_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates24.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates24.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:731b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v64.service"]) subprocess.run(["systemctl", "start", "pings2_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v64.service"]) def kharej4s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/privates24.sh"): os.remove("/etc/privates24.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:731b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:731b::2/64", "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates24.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config4 up\n") f.write("ip addr add 2002:731b::1/64 dev iran2config4\n") f.write("ip -6 route add 2002:731b::2/64 dev iran2config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config4 mtu {mtu_value}\n" with open("/etc/privates24.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:731b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v64.sh", 0o755) pings2_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 server 2 def adds2_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates25.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates25.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:741b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v65.service"]) subprocess.run(["systemctl", "start", "pings2_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v65.service"]) def kharej5s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/privates25.sh"): os.remove("/etc/privates25.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:741b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:741b::2/64", "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates25.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config5 up\n") f.write("ip addr add 2002:741b::1/64 dev iran2config5\n") f.write("ip -6 route add 2002:741b::2/64 dev iran2config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config5 mtu {mtu_value}\n" with open("/etc/privates25.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:741b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v65.sh", 0o755) pings2_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 server 2 def adds2_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates26.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates26.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:751b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v66.service"]) subprocess.run(["systemctl", "start", "pings2_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v66.service"]) def kharej6s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/privates26.sh"): os.remove("/etc/privates26.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:751b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:751b::2/64", "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates26.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config6 up\n") f.write("ip addr add 2002:751b::1/64 dev iran2config6\n") f.write("ip -6 route add 2002:751b::2/64 dev iran2config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config6 mtu {mtu_value}\n" with open("/etc/privates26.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:751b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v66.sh", 0o755) pings2_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 def adds2_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates27.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates27.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:761b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v67.service"]) subprocess.run(["systemctl", "start", "pings2_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v67.service"]) def kharej7s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/privates27.sh"): os.remove("/etc/privates27.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:761b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:761b::2/64", "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates27.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config7 up\n") f.write("ip addr add 2002:761b::1/64 dev iran2config7\n") f.write("ip -6 route add 2002:761b::2/64 dev iran2config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config7 mtu {mtu_value}\n" with open("/etc/privates27.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:761b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v67.sh", 0o755) pings2_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 server 2 def adds2_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates28.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates28.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:771b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v68.service"]) subprocess.run(["systemctl", "start", "pings2_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v68.service"]) def kharej8s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/privates28.sh"): os.remove("/etc/privates28.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:771b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:771b::2/64", "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates28.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config8 up\n") f.write("ip addr add 2002:771b::1/64 dev iran2config8\n") f.write("ip -6 route add 2002:771b::2/64 dev iran2config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config8 mtu {mtu_value}\n" with open("/etc/privates28.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:771b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v68.sh", 0o755) pings2_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 server 2 def adds2_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates29.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates29.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:781b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v69.service"]) subprocess.run(["systemctl", "start", "pings2_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v69.service"]) def kharej9s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/privates29.sh"): os.remove("/etc/privates29.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:781b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:781b::2/64", "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates29.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config9 up\n") f.write("ip addr add 2002:781b::1/64 dev iran2config9\n") f.write("ip -6 route add 2002:781b::2/64 dev iran2config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config9 mtu {mtu_value}\n" with open("/etc/privates29.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:781b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings2_v69.sh", 0o755) pings2_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 server 2 def adds2_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates210.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates210.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs2_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:791b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v610.service"]) subprocess.run(["systemctl", "start", "pings2_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v610.service"]) def kharej10s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/privates210.sh"): os.remove("/etc/privates210.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:791b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:791b::2/64", "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates210.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config10 up\n") f.write("ip addr add 2002:791b::1/64 dev iran2config10\n") f.write("ip -6 route add 2002:791b::2/64 dev iran2config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran2config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config10 mtu {mtu_value}\n" with open("/etc/privates210.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:791b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6s210.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6s210.sh", 0o755) pings2_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 def runs2_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:701b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/privates21.sh"): os.remove("/etc/privates21.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:701b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:701b::1/64", "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates21.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config1 up\n") f.write("ip addr add 2002:701b::2/64 dev iran2config1\n") f.write("ip -6 route add 2002:701b::1/64 dev iran2config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config1 mtu {mtu_value}\n" with open("/etc/privates21.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:70{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:701b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v61.sh", 0o755) pings2_v61_service() ## IRAN2 server 2 def runs2_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:711b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/privates22.sh"): os.remove("/etc/privates22.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:711b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:711b::1/64", "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates22.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config2 up\n") f.write("ip addr add 2002:711b::2/64 dev iran2config2\n") f.write("ip -6 route add 2002:711b::1/64 dev iran2config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config2 mtu {mtu_value}\n" with open("/etc/privates22.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:71{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:711b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v62.sh", 0o755) pings2_v62_service() ## IRAN3 server 2 def runs2_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:721b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/privates23.sh"): os.remove("/etc/privates23.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:721b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:721b::1/64", "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates23.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config3 up\n") f.write("ip addr add 2002:721b::2/64 dev iran2config3\n") f.write("ip -6 route add 2002:721b::1/64 dev iran2config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config3 mtu {mtu_value}\n" with open("/etc/privates23.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:72{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:721b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v63.sh", 0o755) pings2_v63_service() ## IRAN4 def runs2_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:731b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/privates24.sh"): os.remove("/etc/privates24.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:731b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:731b::1/64", "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates24.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config4 up\n") f.write("ip addr add 2002:731b::2/64 dev iran2config4\n") f.write("ip -6 route add 2002:731b::1/64 dev iran2config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config4 mtu {mtu_value}\n" with open("/etc/privates24.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:73{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:731b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v64.sh", 0o755) pings2_v64_service() ## IRAN5 server 2 def runs2_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:741b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/privates25.sh"): os.remove("/etc/privates25.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:741b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:741b::1/64", "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates25.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config5 up\n") f.write("ip addr add 2002:741b::2/64 dev iran2config5\n") f.write("ip -6 route add 2002:741b::1/64 dev iran2config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config5 mtu {mtu_value}\n" with open("/etc/privates25.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:74{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:741b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v65.sh", 0o755) pings2_v65_service() ## IRAN6 server 2 def runs2_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:751b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/privates26.sh"): os.remove("/etc/privates26.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:751b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:751b::1/64", "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates26.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config6 up\n") f.write("ip addr add 2002:751b::2/64 dev iran2config6\n") f.write("ip -6 route add 2002:751b::1/64 dev iran2config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config6 mtu {mtu_value}\n" with open("/etc/privates26.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:75{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:751b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v66.sh", 0o755) pings2_v66_service() ## IRAN7 server 2 def runs2_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:761b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/privates27.sh"): os.remove("/etc/privates27.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:761b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:761b::1/64", "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates27.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config7 up\n") f.write("ip addr add 2002:761b::2/64 dev iran2config7\n") f.write("ip -6 route add 2002:761b::1/64 dev iran2config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config7 mtu {mtu_value}\n" with open("/etc/privates27.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:76{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:761b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v67.sh", 0o755) pings2_v67_service() ## IRAN8 server 2 def runs2_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:771b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/privates28.sh"): os.remove("/etc/privates28.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:771b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:771b::1/64", "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates28.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config8 up\n") f.write("ip addr add 2002:771b::2/64 dev iran2config8\n") f.write("ip -6 route add 2002:771b::1/64 dev iran2config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config8 mtu {mtu_value}\n" with open("/etc/privates28.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:77{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:771b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v68.sh", 0o755) pings2_v68_service() ## IRAN9 def runs2_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:781b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/privates29.sh"): os.remove("/etc/privates29.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:781b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:781b::1/64", "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates29.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config9 up\n") f.write("ip addr add 2002:781b::2/64 dev iran2config9\n") f.write("ip -6 route add 2002:781b::1/64 dev iran2config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config9 mtu {mtu_value}\n" with open("/etc/privates29.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:78{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:781b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v69.sh", 0o755) pings2_v69_service() ## IRAN10 server 2s def runs2_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:791b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10s2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/privates210.sh"): os.remove("/etc/privates210.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran2config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran2config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:791b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:791b::1/64", "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran2config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran2config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates210.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran2config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran2config10 up\n") f.write("ip addr add 2002:791b::2/64 dev iran2config10\n") f.write("ip -6 route add 2002:791b::1/64 dev iran2config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran2config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran2config10 mtu {mtu_value}\n" with open("/etc/privates210.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds2_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs2_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:79{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:791b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings2_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings2_v610.sh", 0o755) pings2_v610_service() # server 1 3iran 10kharej def adds1_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates11.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates11.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v61.service"]) subprocess.run(["systemctl", "start", "pings1_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v61.service"]) def kharej1s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/privates11.sh"): os.remove("/etc/privates11.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates11.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config1 up\n") f.write("ip addr add 2002:801b::1/64 dev iran1config1\n") f.write("ip -6 route add 2002:801b::2/64 dev iran1config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config1 mtu {mtu_value}\n" with open("/etc/privates11.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v61.sh", 0o755) pings1_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 server 1 def adds1_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates12.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates12.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings2_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings2_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings2_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings2_v62.service"]) subprocess.run(["systemctl", "start", "pings2_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings2_v62.service"]) def kharej2s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/privates12.sh"): os.remove("/etc/privates12.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates12.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config2 up\n") f.write("ip addr add 2002:811b::1/64 dev iran1config2\n") f.write("ip -6 route add 2002:811b::2/64 dev iran1config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config2 mtu {mtu_value}\n" with open("/etc/privates12.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v62.sh", 0o755) pings1_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 server 1 def adds1_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates13.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates13.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:821b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v63.service"]) subprocess.run(["systemctl", "start", "pings1_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v63.service"]) def adds1_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates13.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates13.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:821b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v63.service"]) subprocess.run(["systemctl", "start", "pings1_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v63.service"]) def kharej3s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/privates13.sh"): os.remove("/etc/privates13.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates13.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config3 up\n") f.write("ip addr add 2002:821b::1/64 dev iran1config3\n") f.write("ip -6 route add 2002:821b::2/64 dev iran1config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config3 mtu {mtu_value}\n" with open("/etc/privates13.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v63.sh", 0o755) pings1_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 server 1 def adds1_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates14.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates14.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v64.service"]) subprocess.run(["systemctl", "start", "pings1_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v64.service"]) def kharej4s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/privates14.sh"): os.remove("/etc/privates14.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates14.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config4 up\n") f.write("ip addr add 2002:831b::1/64 dev iran1config4\n") f.write("ip -6 route add 2002:831b::2/64 dev iran1config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config4 mtu {mtu_value}\n" with open("/etc/privates14.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v64.sh", 0o755) pings1_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 server 1 def adds1_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates15.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates15.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v65.service"]) subprocess.run(["systemctl", "start", "pings1_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v65.service"]) def kharej5s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/privates15.sh"): os.remove("/etc/privates15.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates15.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config5 up\n") f.write("ip addr add 2002:841b::1/64 dev iran1config5\n") f.write("ip -6 route add 2002:841b::2/64 dev iran1config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config5 mtu {mtu_value}\n" with open("/etc/privates15.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v65.sh", 0o755) pings1_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 server 1 def adds1_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates16.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates16.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v66.service"]) subprocess.run(["systemctl", "start", "pings1_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v66.service"]) def kharej6s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/privates16.sh"): os.remove("/etc/privates16.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::2/64", "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates16.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config6 up\n") f.write("ip addr add 2002:851b::1/64 dev iran1config6\n") f.write("ip -6 route add 2002:851b::2/64 dev iran1config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config6 mtu {mtu_value}\n" with open("/etc/privates16.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v66.sh", 0o755) pings1_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 server 1 def adds1_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates17.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates17.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v67.service"]) subprocess.run(["systemctl", "start", "pings1_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v67.service"]) def kharej7s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/privates17.sh"): os.remove("/etc/privates17.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::2/64", "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates17.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config7 up\n") f.write("ip addr add 2002:861b::1/64 dev iran1config7\n") f.write("ip -6 route add 2002:861b::2/64 dev iran1config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config7 mtu {mtu_value}\n" with open("/etc/privates17.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v67.sh", 0o755) pings1_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 server 1 def adds1_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates18.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates18.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v68.service"]) subprocess.run(["systemctl", "start", "pings1_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v68.service"]) def kharej8s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/privates18.sh"): os.remove("/etc/privates18.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::2/64", "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates18.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config8 up\n") f.write("ip addr add 2002:871b::1/64 dev iran1config8\n") f.write("ip -6 route add 2002:871b::2/64 dev iran1config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config8 mtu {mtu_value}\n" with open("/etc/privates18.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v68.sh", 0o755) pings1_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 server 1 def adds1_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates19.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates19.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:881b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v69.service"]) subprocess.run(["systemctl", "start", "pings1_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v69.service"]) def kharej9s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/privates19.sh"): os.remove("/etc/privates19.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::2/64", "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates19.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config9 up\n") f.write("ip addr add 2002:881b::1/64 dev iran1config9\n") f.write("ip -6 route add 2002:881b::2/64 dev iran1config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config9 mtu {mtu_value}\n" with open("/etc/privates19.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v69.sh", 0o755) pings1_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 server 1 def adds1_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates110.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates110.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs1_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:891b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings1_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings1_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings1_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings1_v610.service"]) subprocess.run(["systemctl", "start", "pings1_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings1_v610.service"]) def kharej10s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/privates110.sh"): os.remove("/etc/privates110.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::2/64", "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates110.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config10 up\n") f.write("ip addr add 2002:891b::1/64 dev iran1config10\n") f.write("ip -6 route add 2002:891b::2/64 dev iran1config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran1config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config10 mtu {mtu_value}\n" with open("/etc/privates110.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings1_v610.sh", 0o755) pings1_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 def runs1_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/privates11.sh"): os.remove("/etc/privates11.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates11.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config1 up\n") f.write("ip addr add 2002:801b::2/64 dev iran1config1\n") f.write("ip -6 route add 2002:801b::1/64 dev iran1config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config1 mtu {mtu_value}\n" with open("/etc/privates11.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v61.sh", 0o755) pings1_v61_service() ## IRAN2 server 1 def runs1_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/privates12.sh"): os.remove("/etc/privates12.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates12.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config2 up\n") f.write("ip addr add 2002:811b::2/64 dev iran1config2\n") f.write("ip -6 route add 2002:811b::1/64 dev iran1config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config2 mtu {mtu_value}\n" with open("/etc/privates12.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v62.sh", 0o755) pings1_v62_service() ## IRAN3 server 1 def runs1_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:821b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/privates13.sh"): os.remove("/etc/privates13.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates13.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config3 up\n") f.write("ip addr add 2002:821b::2/64 dev iran1config3\n") f.write("ip -6 route add 2002:821b::1/64 dev iran1config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config3 mtu {mtu_value}\n" with open("/etc/privates13.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v63.sh", 0o755) pings1_v63_service() ## IRAN4 server 1 def runs1_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/privates14.sh"): os.remove("/etc/privates14.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates14.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config4 up\n") f.write("ip addr add 2002:831b::2/64 dev iran1config4\n") f.write("ip -6 route add 2002:831b::1/64 dev iran1config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config4 mtu {mtu_value}\n" with open("/etc/privates14.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v64.sh", 0o755) pings1_v64_service() ## IRAN5 server 1 def runs1_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/privates15.sh"): os.remove("/etc/privates15.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates15.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config5 up\n") f.write("ip addr add 2002:841b::2/64 dev iran1config5\n") f.write("ip -6 route add 2002:841b::1/64 dev iran1config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config5 mtu {mtu_value}\n" with open("/etc/privates15.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v65.sh", 0o755) pings1_v65_service() ## IRAN6 server 1 def runs1_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/privates16.sh"): os.remove("/etc/privates16.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::1/64", "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates16.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config6 up\n") f.write("ip addr add 2002:851b::2/64 dev iran1config6\n") f.write("ip -6 route add 2002:851b::1/64 dev iran1config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config6 mtu {mtu_value}\n" with open("/etc/privates16.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v66.sh", 0o755) pings1_v66_service() ## IRAN7 server 1 def runs1_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/privates17.sh"): os.remove("/etc/privates17.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::1/64", "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates17.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config7 up\n") f.write("ip addr add 2002:861b::2/64 dev iran1config7\n") f.write("ip -6 route add 2002:861b::1/64 dev iran1config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config7 mtu {mtu_value}\n" with open("/etc/privates17.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v67.sh", 0o755) pings1_v67_service() ## IRAN8 server 1 def runs1_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/privates18.sh"): os.remove("/etc/privates18.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::1/64", "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates18.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config8 up\n") f.write("ip addr add 2002:871b::2/64 dev iran1config8\n") f.write("ip -6 route add 2002:871b::1/64 dev iran1config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config8 mtu {mtu_value}\n" with open("/etc/privates18.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v68.sh", 0o755) pings1_v68_service() ## IRAN9 server 1 def runs1_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:881b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/privates19.sh"): os.remove("/etc/privates19.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::1/64", "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates19.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config9 up\n") f.write("ip addr add 2002:881b::2/64 dev iran1config9\n") f.write("ip -6 route add 2002:881b::1/64 dev iran1config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config9 mtu {mtu_value}\n" with open("/etc/privates19.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v69.sh", 0o755) pings1_v69_service() ## IRAN10 server 1s def runs1_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:891b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10s1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/privates110.sh"): os.remove("/etc/privates110.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran1config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran1config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::1/64", "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran1config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran1config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates110.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran1config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran1config10 up\n") f.write("ip addr add 2002:891b::2/64 dev iran1config10\n") f.write("ip -6 route add 2002:891b::1/64 dev iran1config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran1config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran1config10 mtu {mtu_value}\n" with open("/etc/privates110.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds1_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs1_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings1_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings1_v610.sh", 0o755) pings1_v610_service() # server 3 iran for 10 kharej 5 iran def priviran5_kh_ip3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config list [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Which server:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_private_5iranmenu3() break elif server_type == "2": iran_private_5iranmenu3() break elif server_type == "0": os.system("clear") priviran5_mnu_ip() break else: print("Invalid choice.") def kharej_private_5iranmenu3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033\033[92m[10]Kharej [5]IRAN\033[96m Config list [3]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1s3_private_menu() break elif server_type == "2": kharej2s3_private_menu() break elif server_type == "3": kharej3s3_private_menu() break elif server_type == "4": kharej4s3_private_menu() break elif server_type == "5": kharej5s3_private_menu() break elif server_type == "6": kharej6s3_private_menu() break elif server_type == "7": kharej7s3_private_menu() break elif server_type == "8": kharej8s3_private_menu() break elif server_type == "9": kharej9s3_private_menu() break elif server_type == "10": kharej10s3_private_menu() break elif server_type == "0": os.system("clear") priviran5_kh_ip3() break else: print("Invalid choice.") def iran_private_5iranmenu3(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10]KHAREJ [5]IRAN - Config list [3] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran{}s3_private_menu".format(i) globals()[menu_name]() ## Kharej 1 server 3 def adds3_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates31.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates31.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:601b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v61.service"]) subprocess.run(["systemctl", "start", "pings3_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v61.service"]) def kharej1s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/privates31.sh"): os.remove("/etc/privates31.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:601b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:601b::2/64", "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates31.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config1 up\n") f.write("ip addr add 2002:601b::1/64 dev iran3config1\n") f.write("ip -6 route add 2002:601b::2/64 dev iran3config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config1 mtu {mtu_value}\n" with open("/etc/privates31.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:601b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v61.sh", 0o755) pings3_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 server 3 def adds3_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates32.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates32.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:611b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v62.service"]) subprocess.run(["systemctl", "start", "pings3_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v62.service"]) def kharej2s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/privates32.sh"): os.remove("/etc/privates32.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:611b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:611b::2/64", "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates32.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config2 up\n") f.write("ip addr add 2002:611b::1/64 dev iran3config2\n") f.write("ip -6 route add 2002:611b::2/64 dev iran3config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config2 mtu {mtu_value}\n" with open("/etc/privates32.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:611b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v62.sh", 0o755) pings3_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 server 3 def adds3_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates33.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates33.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:621b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v63.service"]) subprocess.run(["systemctl", "start", "pings3_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v63.service"]) def kharej3s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/privates33.sh"): os.remove("/etc/privates33.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:621b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:621b::2/64", "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates33.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config3 up\n") f.write("ip addr add 2002:621b::1/64 dev iran3config3\n") f.write("ip -6 route add 2002:621b::2/64 dev iran3config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config3 mtu {mtu_value}\n" with open("/etc/privates33.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:621b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v63.sh", 0o755) pings3_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 server 3 def adds3_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates34.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates34.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:631b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v64.service"]) subprocess.run(["systemctl", "start", "pings3_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v64.service"]) def kharej4s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/privates34.sh"): os.remove("/etc/privates34.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:631b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:631b::2/64", "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates34.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config4 up\n") f.write("ip addr add 2002:631b::1/64 dev iran3config4\n") f.write("ip -6 route add 2002:631b::2/64 dev iran3config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config4 mtu {mtu_value}\n" with open("/etc/privates34.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:631b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v64.sh", 0o755) pings3_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 server 3 def adds3_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates35.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates35.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:641b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v65.service"]) subprocess.run(["systemctl", "start", "pings3_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v65.service"]) def kharej5s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/privates35.sh"): os.remove("/etc/privates35.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:641b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:641b::2/64", "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates35.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config5 up\n") f.write("ip addr add 2002:641b::1/64 dev iran3config5\n") f.write("ip -6 route add 2002:641b::2/64 dev iran3config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config5 mtu {mtu_value}\n" with open("/etc/privates35.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:641b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v65.sh", 0o755) pings3_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 server 3 def adds3_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates36.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates36.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:651b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v66.service"]) subprocess.run(["systemctl", "start", "pings3_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v66.service"]) def kharej6s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/privates36.sh"): os.remove("/etc/privates36.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:651b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:651b::2/64", "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates36.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config6 up\n") f.write("ip addr add 2002:651b::1/64 dev iran3config6\n") f.write("ip -6 route add 2002:651b::2/64 dev iran3config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config6 mtu {mtu_value}\n" with open("/etc/privates36.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:651b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v66.sh", 0o755) pings3_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 server 3 def adds3_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates37.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates37.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:661b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v67.service"]) subprocess.run(["systemctl", "start", "pings3_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v67.service"]) def kharej7s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/privates37.sh"): os.remove("/etc/privates37.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:661b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:661b::2/64", "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates37.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config7 up\n") f.write("ip addr add 2002:661b::1/64 dev iran3config7\n") f.write("ip -6 route add 2002:661b::2/64 dev iran3config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config7 mtu {mtu_value}\n" with open("/etc/privates37.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:661b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v67.sh", 0o755) pings3_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 server 3 def adds3_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates38.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates38.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:671b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v68.service"]) subprocess.run(["systemctl", "start", "pings3_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v68.service"]) def kharej8s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/privates38.sh"): os.remove("/etc/privates38.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:671b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:671b::2/64", "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates38.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config8 up\n") f.write("ip addr add 2002:671b::1/64 dev iran3config8\n") f.write("ip -6 route add 2002:671b::2/64 dev iran3config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config8 mtu {mtu_value}\n" with open("/etc/privates38.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:671b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v68.sh", 0o755) pings3_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 server 3 def adds3_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates39.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates39.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:681b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v69.service"]) subprocess.run(["systemctl", "start", "pings3_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v69.service"]) def kharej9s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/privates39.sh"): os.remove("/etc/privates39.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:681b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:681b::2/64", "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates39.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config9 up\n") f.write("ip addr add 2002:681b::1/64 dev iran3config9\n") f.write("ip -6 route add 2002:681b::2/64 dev iran3config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config9 mtu {mtu_value}\n" with open("/etc/privates39.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:681b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings3_v69.sh", 0o755) pings3_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 server 3 def adds3_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates310.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates310.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs3_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:691b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings3_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings3_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings3_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings3_v610.service"]) subprocess.run(["systemctl", "start", "pings3_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings3_v610.service"]) def kharej10s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/privates310.sh"): os.remove("/etc/privates310.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:691b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:691b::2/64", "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates310.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config10 up\n") f.write("ip addr add 2002:691b::1/64 dev iran3config10\n") f.write("ip -6 route add 2002:691b::2/64 dev iran3config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran3config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config10 mtu {mtu_value}\n" with open("/etc/privates310.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:691b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6s310.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6s310.sh", 0o755) pings3_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 def runs3_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:601b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/privates31.sh"): os.remove("/etc/privates31.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:601b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:601b::1/64", "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates31.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config1 up\n") f.write("ip addr add 2002:601b::2/64 dev iran3config1\n") f.write("ip -6 route add 2002:601b::1/64 dev iran3config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config1 mtu {mtu_value}\n" with open("/etc/privates31.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:60{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:601b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v61.sh", 0o755) pings3_v61_service() ## IRAN2 server 3 def runs3_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:611b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/privates32.sh"): os.remove("/etc/privates32.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:611b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:611b::1/64", "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates32.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config2 up\n") f.write("ip addr add 2002:611b::2/64 dev iran3config2\n") f.write("ip -6 route add 2002:611b::1/64 dev iran3config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config2 mtu {mtu_value}\n" with open("/etc/privates32.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:61{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:611b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v62.sh", 0o755) pings3_v62_service() ## IRAN3 server 3 def runs3_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:621b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/privates33.sh"): os.remove("/etc/privates33.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:621b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:621b::1/64", "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates33.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config3 up\n") f.write("ip addr add 2002:621b::2/64 dev iran3config3\n") f.write("ip -6 route add 2002:621b::1/64 dev iran3config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config3 mtu {mtu_value}\n" with open("/etc/privates33.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:62{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:621b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v63.sh", 0o755) pings3_v63_service() ## IRAN4 server 3 def runs3_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:631b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/privates34.sh"): os.remove("/etc/privates34.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:631b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:631b::1/64", "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates34.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config4 up\n") f.write("ip addr add 2002:631b::2/64 dev iran3config4\n") f.write("ip -6 route add 2002:631b::1/64 dev iran3config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config4 mtu {mtu_value}\n" with open("/etc/privates34.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:63{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:631b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v64.sh", 0o755) pings3_v64_service() ## IRAN5 server 3 def runs3_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:641b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/privates35.sh"): os.remove("/etc/privates35.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:641b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:641b::1/64", "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates35.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config5 up\n") f.write("ip addr add 2002:641b::2/64 dev iran3config5\n") f.write("ip -6 route add 2002:641b::1/64 dev iran3config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config5 mtu {mtu_value}\n" with open("/etc/privates35.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:64{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:641b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v65.sh", 0o755) pings3_v65_service() ## IRAN6 server 3 def runs3_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:651b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/privates36.sh"): os.remove("/etc/privates36.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:651b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:651b::1/64", "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates36.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config6 up\n") f.write("ip addr add 2002:651b::2/64 dev iran3config6\n") f.write("ip -6 route add 2002:651b::1/64 dev iran3config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config6 mtu {mtu_value}\n" with open("/etc/privates36.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:65{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:651b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v66.sh", 0o755) pings3_v66_service() ## IRAN7 server 3 def runs3_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:661b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/privates37.sh"): os.remove("/etc/privates37.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:661b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:661b::1/64", "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates37.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config7 up\n") f.write("ip addr add 2002:661b::2/64 dev iran3config7\n") f.write("ip -6 route add 2002:661b::1/64 dev iran3config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config7 mtu {mtu_value}\n" with open("/etc/privates37.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:66{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:661b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v67.sh", 0o755) pings3_v67_service() ## IRAN8 server 3 def runs3_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:671b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/privates38.sh"): os.remove("/etc/privates38.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:671b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:671b::1/64", "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates38.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config8 up\n") f.write("ip addr add 2002:671b::2/64 dev iran3config8\n") f.write("ip -6 route add 2002:671b::1/64 dev iran3config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config8 mtu {mtu_value}\n" with open("/etc/privates38.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:67{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:671b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v68.sh", 0o755) pings3_v68_service() ## IRAN9 server 3 def runs3_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:681b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/privates39.sh"): os.remove("/etc/privates39.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:681b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:681b::1/64", "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates39.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config9 up\n") f.write("ip addr add 2002:681b::2/64 dev iran3config9\n") f.write("ip -6 route add 2002:681b::1/64 dev iran3config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config9 mtu {mtu_value}\n" with open("/etc/privates39.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:68{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:681b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v69.sh", 0o755) pings3_v69_service() ## IRAN10 server 3 def runs3_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:691b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10s3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/privates310.sh"): os.remove("/etc/privates310.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server [3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran3config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran3config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:691b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:691b::1/64", "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran3config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran3config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates310.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran3config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran3config10 up\n") f.write("ip addr add 2002:691b::2/64 dev iran3config10\n") f.write("ip -6 route add 2002:691b::1/64 dev iran3config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran3config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran3config10 mtu {mtu_value}\n" with open("/etc/privates310.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds3_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs3_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:69{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:691b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings3_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings3_v610.sh", 0o755) pings3_v610_service() # iran server 4 for 5 iran 10 kharej def priviran5_kh_ip4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config list [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Which server:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_private_5iranmenu4() break elif server_type == "2": iran_private_5iranmenu4() break elif server_type == "0": os.system("clear") priviran5_mnu_ip() break else: print("Invalid choice.") def kharej_private_5iranmenu4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config list [4]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1s4_private_menu() break elif server_type == "2": kharej2s4_private_menu() break elif server_type == "3": kharej3s4_private_menu() break elif server_type == "4": kharej4s4_private_menu() break elif server_type == "5": kharej5s4_private_menu() break elif server_type == "6": kharej6s4_private_menu() break elif server_type == "7": kharej7s4_private_menu() break elif server_type == "8": kharej8s4_private_menu() break elif server_type == "9": kharej9s4_private_menu() break elif server_type == "10": kharej10s4_private_menu() break elif server_type == "0": os.system("clear") priviran5_mnu_ip() break else: print("Invalid choice.") def iran_private_5iranmenu4(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10]KHAREJ [5]IRAN - Config list [2] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran{}s4_private_menu".format(i) globals()[menu_name]() ## Kharej 1 server 4 def adds4_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates41.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates41.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:501b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v61.service"]) subprocess.run(["systemctl", "start", "pings4_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v61.service"]) def kharej1s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/privates41.sh"): os.remove("/etc/privates41.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:501b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:501b::2/64", "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates41.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config1 up\n") f.write("ip addr add 2002:501b::1/64 dev iran4config1\n") f.write("ip -6 route add 2002:501b::2/64 dev iran4config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config1 mtu {mtu_value}\n" with open("/etc/privates41.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:501b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v61.sh", 0o755) pings4_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 server 4 def adds4_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates42.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates42.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:511b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v62.service"]) subprocess.run(["systemctl", "start", "pings4_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v62.service"]) def kharej2s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/privates42.sh"): os.remove("/etc/privates42.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:511b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:511b::2/64", "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates42.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config2 up\n") f.write("ip addr add 2002:511b::1/64 dev iran4config2\n") f.write("ip -6 route add 2002:511b::2/64 dev iran4config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config2 mtu {mtu_value}\n" with open("/etc/privates42.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:511b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v62.sh", 0o755) pings4_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 server 4 def adds4_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates43.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates43.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:521b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v63.service"]) subprocess.run(["systemctl", "start", "pings4_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v63.service"]) def kharej3s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/privates43.sh"): os.remove("/etc/privates43.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:521b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:521b::2/64", "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates43.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config3 up\n") f.write("ip addr add 2002:521b::1/64 dev iran4config3\n") f.write("ip -6 route add 2002:521b::2/64 dev iran4config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config3 mtu {mtu_value}\n" with open("/etc/privates43.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:521b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v63.sh", 0o755) pings4_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 server 4 def adds4_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates44.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates44.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:531b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v64.service"]) subprocess.run(["systemctl", "start", "pings4_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v64.service"]) def kharej4s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/privates44.sh"): os.remove("/etc/privates44.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:531b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:531b::2/64", "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates44.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config4 up\n") f.write("ip addr add 2002:531b::1/64 dev iran4config4\n") f.write("ip -6 route add 2002:531b::2/64 dev iran4config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config4 mtu {mtu_value}\n" with open("/etc/privates44.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:531b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v64.sh", 0o755) pings4_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 server 4 def adds4_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates45.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates45.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:541b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v65.service"]) subprocess.run(["systemctl", "start", "pings4_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v65.service"]) def kharej5s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/privates45.sh"): os.remove("/etc/privates45.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:541b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:541b::2/64", "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates45.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config5 up\n") f.write("ip addr add 2002:541b::1/64 dev iran4config5\n") f.write("ip -6 route add 2002:541b::2/64 dev iran4config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config5 mtu {mtu_value}\n" with open("/etc/privates45.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:541b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v65.sh", 0o755) pings4_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 server 4 def adds4_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates46.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates46.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:551b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v66.service"]) subprocess.run(["systemctl", "start", "pings4_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v66.service"]) def kharej6s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/privates46.sh"): os.remove("/etc/privates46.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:551b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:551b::2/64", "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates46.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config6 up\n") f.write("ip addr add 2002:551b::1/64 dev iran4config6\n") f.write("ip -6 route add 2002:551b::2/64 dev iran4config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config6 mtu {mtu_value}\n" with open("/etc/privates46.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:551b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v66.sh", 0o755) pings4_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 server 4 def adds4_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates47.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates47.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:561b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v67.service"]) subprocess.run(["systemctl", "start", "pings4_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v67.service"]) def kharej7s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/privates47.sh"): os.remove("/etc/privates47.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:561b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:561b::2/64", "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates47.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config7 up\n") f.write("ip addr add 2002:561b::1/64 dev iran4config7\n") f.write("ip -6 route add 2002:561b::2/64 dev iran4config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config7 mtu {mtu_value}\n" with open("/etc/privates47.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:561b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v67.sh", 0o755) pings4_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 server 4 def adds4_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates48.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates48.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:571b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v68.service"]) subprocess.run(["systemctl", "start", "pings4_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v68.service"]) def kharej8s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/privates48.sh"): os.remove("/etc/privates48.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:571b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:571b::2/64", "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates48.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config8 up\n") f.write("ip addr add 2002:571b::1/64 dev iran4config8\n") f.write("ip -6 route add 2002:571b::2/64 dev iran4config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config8 mtu {mtu_value}\n" with open("/etc/privates48.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:571b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v68.sh", 0o755) pings4_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 server 4 def adds4_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates49.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates49.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:581b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v69.service"]) subprocess.run(["systemctl", "start", "pings4_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v69.service"]) def kharej9s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/privates49.sh"): os.remove("/etc/privates49.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:581b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:581b::2/64", "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates49.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config9 up\n") f.write("ip addr add 2002:581b::1/64 dev iran4config9\n") f.write("ip -6 route add 2002:581b::2/64 dev iran4config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config9 mtu {mtu_value}\n" with open("/etc/privates49.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:581b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings4_v69.sh", 0o755) pings4_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 server 4 def adds4_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates410.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates410.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs4_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:591b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings4_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings4_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings4_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings4_v610.service"]) subprocess.run(["systemctl", "start", "pings4_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings4_v610.service"]) def kharej10s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/privates410.sh"): os.remove("/etc/privates410.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:591b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:591b::2/64", "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates410.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config10 up\n") f.write("ip addr add 2002:591b::1/64 dev iran4config10\n") f.write("ip -6 route add 2002:591b::2/64 dev iran4config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran4config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config10 mtu {mtu_value}\n" with open("/etc/privates410.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:591b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6s410.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6s410.sh", 0o755) pings4_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 server 4 def runs4_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:501b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/privates41.sh"): os.remove("/etc/privates41.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:501b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:501b::1/64", "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates41.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config1 up\n") f.write("ip addr add 2002:501b::2/64 dev iran4config1\n") f.write("ip -6 route add 2002:501b::1/64 dev iran4config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config1 mtu {mtu_value}\n" with open("/etc/privates41.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:50{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:501b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v61.sh", 0o755) pings4_v61_service() ## IRAN2 server 4 def runs4_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:511b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/privates42.sh"): os.remove("/etc/privates42.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:511b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:511b::1/64", "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates42.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config2 up\n") f.write("ip addr add 2002:511b::2/64 dev iran4config2\n") f.write("ip -6 route add 2002:511b::1/64 dev iran4config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config2 mtu {mtu_value}\n" with open("/etc/privates42.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:51{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:511b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v62.sh", 0o755) pings4_v62_service() ## IRAN3 server 4 def runs4_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:521b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/privates43.sh"): os.remove("/etc/privates43.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:521b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:521b::1/64", "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates43.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config3 up\n") f.write("ip addr add 2002:521b::2/64 dev iran4config3\n") f.write("ip -6 route add 2002:521b::1/64 dev iran4config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config3 mtu {mtu_value}\n" with open("/etc/privates43.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:52{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:521b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v63.sh", 0o755) pings4_v63_service() ## IRAN4 server 4 def runs4_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:531b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/privates44.sh"): os.remove("/etc/privates44.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:531b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:531b::1/64", "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates44.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config4 up\n") f.write("ip addr add 2002:531b::2/64 dev iran4config4\n") f.write("ip -6 route add 2002:531b::1/64 dev iran4config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config4 mtu {mtu_value}\n" with open("/etc/privates44.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:53{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:531b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v64.sh", 0o755) pings4_v64_service() ## IRAN5 server 4 def runs4_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:541b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/privates45.sh"): os.remove("/etc/privates45.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:541b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:541b::1/64", "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates45.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config5 up\n") f.write("ip addr add 2002:541b::2/64 dev iran4config5\n") f.write("ip -6 route add 2002:541b::1/64 dev iran4config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config5 mtu {mtu_value}\n" with open("/etc/privates45.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:54{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:541b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v65.sh", 0o755) pings4_v65_service() ## IRAN6 server 4 def runs4_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:551b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/privates46.sh"): os.remove("/etc/privates46.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:551b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:551b::1/64", "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates46.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config6 up\n") f.write("ip addr add 2002:551b::2/64 dev iran4config6\n") f.write("ip -6 route add 2002:551b::1/64 dev iran4config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config6 mtu {mtu_value}\n" with open("/etc/privates46.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:55{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:551b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v66.sh", 0o755) pings4_v66_service() ## IRAN7 server 4 def runs4_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:561b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/privates47.sh"): os.remove("/etc/privates47.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:561b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:561b::1/64", "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates47.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config7 up\n") f.write("ip addr add 2002:561b::2/64 dev iran4config7\n") f.write("ip -6 route add 2002:561b::1/64 dev iran4config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config7 mtu {mtu_value}\n" with open("/etc/privates47.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:56{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:561b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v67.sh", 0o755) pings4_v67_service() ## IRAN8 server 4 def runs4_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:571b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/privates48.sh"): os.remove("/etc/privates48.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:571b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:571b::1/64", "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates48.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config8 up\n") f.write("ip addr add 2002:571b::2/64 dev iran4config8\n") f.write("ip -6 route add 2002:571b::1/64 dev iran4config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config8 mtu {mtu_value}\n" with open("/etc/privates48.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:57{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:571b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v68.sh", 0o755) pings4_v68_service() ## IRAN9 server 4 def runs4_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:581b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/privates49.sh"): os.remove("/etc/privates49.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:581b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:581b::1/64", "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates49.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config9 up\n") f.write("ip addr add 2002:581b::2/64 dev iran4config9\n") f.write("ip -6 route add 2002:581b::1/64 dev iran4config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config9 mtu {mtu_value}\n" with open("/etc/privates49.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:58{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:581b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v69.sh", 0o755) pings4_v69_service() ## IRAN10 server 4 def runs4_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:591b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10s4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/privates410.sh"): os.remove("/etc/privates410.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran4config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran4config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:591b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:591b::1/64", "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran4config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran4config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates410.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran4config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran4config10 up\n") f.write("ip addr add 2002:591b::2/64 dev iran4config10\n") f.write("ip -6 route add 2002:591b::1/64 dev iran4config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran4config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran4config10 mtu {mtu_value}\n" with open("/etc/privates410.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds4_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs4_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:59{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:591b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings4_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings4_v610.sh", 0o755) pings4_v610_service() # server 5 for iran 5 kharej 10 def priviran5_kh_ip5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config list [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Which server:\033[0m") print("1. \033[92mKHAREJ\033[0m") print("2. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_private_5iranmenu5() break elif server_type == "2": iran_private_5iranmenu5() break elif server_type == "0": os.system("clear") priviran5_mnu_ip() break else: print("Invalid choice.") def kharej_private_5iranmenu5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej [5]IRAN\033[96m Config list [5]\033[93m Menu\033[0m" ) print( '\033[92m "-"\033[93m══════════════════════════════════════════════════════════════════════\033[0m' ) print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1s5_private_menu() break elif server_type == "2": kharej2s5_private_menu() break elif server_type == "3": kharej3s5_private_menu() break elif server_type == "4": kharej4s5_private_menu() break elif server_type == "5": kharej5s5_private_menu() break elif server_type == "6": kharej6s5_private_menu() break elif server_type == "7": kharej7s5_private_menu() break elif server_type == "8": kharej8s5_private_menu() break elif server_type == "9": kharej9s5_private_menu() break elif server_type == "10": kharej10s5_private_menu() break elif server_type == "0": os.system("clear") priviran5_mnu_ip() break else: print("Invalid choice.") def iran_private_5iranmenu5(): print("\033[93m────────────────────────────────────────────────────\033[0m") display_notification("\033[93m[10]KHAREJ [5]IRAN - Config list [5] !\033[0m") print("\033[93m────────────────────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran{}s5_private_menu".format(i) globals()[menu_name]() def adds5_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates51.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates51.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:401b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v61.service"]) subprocess.run(["systemctl", "start", "pings5_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v61.service"]) def kharej1s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/privates51.sh"): os.remove("/etc/privates51.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:401b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:401b::2/64", "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates51.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config1 up\n") f.write("ip addr add 2002:401b::1/64 dev iran5config1\n") f.write("ip -6 route add 2002:401b::2/64 dev iran5config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config1 mtu {mtu_value}\n" with open("/etc/privates51.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:401b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v61.sh", 0o755) pings5_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 server 5 def adds5_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates52.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates52.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:411b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v62.service"]) subprocess.run(["systemctl", "start", "pings5_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v62.service"]) def kharej2s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/privates52.sh"): os.remove("/etc/privates52.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:411b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:411b::2/64", "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates52.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config2 up\n") f.write("ip addr add 2002:411b::1/64 dev iran5config2\n") f.write("ip -6 route add 2002:411b::2/64 dev iran5config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config2 mtu {mtu_value}\n" with open("/etc/privates52.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:411b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v62.sh", 0o755) pings5_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 server 5 def adds5_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates53.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates53.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:421b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v63.service"]) subprocess.run(["systemctl", "start", "pings5_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v63.service"]) def kharej3s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/privates53.sh"): os.remove("/etc/privates53.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:421b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:421b::2/64", "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates53.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config3 up\n") f.write("ip addr add 2002:421b::1/64 dev iran5config3\n") f.write("ip -6 route add 2002:421b::2/64 dev iran5config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config3 mtu {mtu_value}\n" with open("/etc/privates53.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:421b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v63.sh", 0o755) pings5_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 server 5 def adds5_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates54.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates54.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:431b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v64.service"]) subprocess.run(["systemctl", "start", "pings5_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v64.service"]) def kharej4s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/privates54.sh"): os.remove("/etc/privates54.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:431b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:431b::2/64", "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates54.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config4 up\n") f.write("ip addr add 2002:431b::1/64 dev iran5config4\n") f.write("ip -6 route add 2002:431b::2/64 dev iran5config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config4 mtu {mtu_value}\n" with open("/etc/privates54.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:431b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v64.sh", 0o755) pings5_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 server 5 def adds5_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates55.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates55.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:441b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v65.service"]) subprocess.run(["systemctl", "start", "pings5_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v65.service"]) def kharej5s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/privates55.sh"): os.remove("/etc/privates55.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:441b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:441b::2/64", "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates55.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config5 up\n") f.write("ip addr add 2002:441b::1/64 dev iran5config5\n") f.write("ip -6 route add 2002:441b::2/64 dev iran5config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config5 mtu {mtu_value}\n" with open("/etc/privates55.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:441b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v65.sh", 0o755) pings5_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 server 5 def adds5_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates56.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates56.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:451b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v66.service"]) subprocess.run(["systemctl", "start", "pings5_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v66.service"]) def kharej6s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/privates56.sh"): os.remove("/etc/privates56.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:451b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:451b::2/64", "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates56.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config6 up\n") f.write("ip addr add 2002:451b::1/64 dev iran5config6\n") f.write("ip -6 route add 2002:451b::2/64 dev iran5config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config6 mtu {mtu_value}\n" with open("/etc/privates56.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:451b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v66.sh", 0o755) pings5_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 server 5 def adds5_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates57.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates57.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:461b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v67.service"]) subprocess.run(["systemctl", "start", "pings5_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v67.service"]) def kharej7s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/privates57.sh"): os.remove("/etc/privates57.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:461b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:461b::2/64", "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates57.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config7 up\n") f.write("ip addr add 2002:461b::1/64 dev iran5config7\n") f.write("ip -6 route add 2002:461b::2/64 dev iran5config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config7 mtu {mtu_value}\n" with open("/etc/privates57.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:461b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v67.sh", 0o755) pings5_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 server 5 def adds5_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates58.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates58.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:471b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v68.service"]) subprocess.run(["systemctl", "start", "pings5_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v68.service"]) def kharej8s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/privates58.sh"): os.remove("/etc/privates58.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:471b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:471b::2/64", "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates58.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config8 up\n") f.write("ip addr add 2002:471b::1/64 dev iran5config8\n") f.write("ip -6 route add 2002:471b::2/64 dev iran5config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config8 mtu {mtu_value}\n" with open("/etc/privates58.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:471b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v68.sh", 0o755) pings5_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 server 5 def adds5_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates59.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates59.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:481b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v69.service"]) subprocess.run(["systemctl", "start", "pings5_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v69.service"]) def kharej9s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/privates59.sh"): os.remove("/etc/privates59.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:481b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:481b::2/64", "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates59.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config9 up\n") f.write("ip addr add 2002:481b::1/64 dev iran5config9\n") f.write("ip -6 route add 2002:481b::2/64 dev iran5config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config9 mtu {mtu_value}\n" with open("/etc/privates59.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:481b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/pings5_v69.sh", 0o755) pings4_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 server 5 def adds5_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/privates510.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/privates510.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def runs5_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:491b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def pings5_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/pings5_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/pings5_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "pings5_v610.service"]) subprocess.run(["systemctl", "start", "pings5_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "pings5_v610.service"]) def kharej10s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/privates510.sh"): os.remove("/etc/privates510.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:491b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:491b::2/64", "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates510.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config10 up\n") f.write("ip addr add 2002:491b::1/64 dev iran5config10\n") f.write("ip -6 route add 2002:491b::2/64 dev iran5config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev iran5config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config10 mtu {mtu_value}\n" with open("/etc/privates510.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:491b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6s510.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6s510.sh", 0o755) pings5_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 server 5 def runs5_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:401b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/privates51.sh"): os.remove("/etc/privates51.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:401b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:401b::1/64", "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config1"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates51.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config1 up\n") f.write("ip addr add 2002:401b::2/64 dev iran5config1\n") f.write("ip -6 route add 2002:401b::1/64 dev iran5config1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config1 mtu {mtu_value}\n" with open("/etc/privates51.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:40{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:401b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v61.sh", 0o755) pings5_v61_service() ## IRAN2 server 5 def runs5_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:411b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/privates52.sh"): os.remove("/etc/privates52.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:411b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:411b::1/64", "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config2"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates52.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config2 up\n") f.write("ip addr add 2002:411b::2/64 dev iran5config2\n") f.write("ip -6 route add 2002:411b::1/64 dev iran5config2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config2 mtu {mtu_value}\n" with open("/etc/privates52.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:41{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:411b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v62.sh", 0o755) pings5_v62_service() ## IRAN3 server 5 def runs5_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:421b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/privates53.sh"): os.remove("/etc/privates53.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:421b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:421b::1/64", "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config3"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates53.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config3 up\n") f.write("ip addr add 2002:421b::2/64 dev iran5config3\n") f.write("ip -6 route add 2002:421b::1/64 dev iran5config3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config3 mtu {mtu_value}\n" with open("/etc/privates53.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:42{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:421b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v63.sh", 0o755) pings5_v63_service() ## IRAN4 server 5 def runs5_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:431b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/privates54.sh"): os.remove("/etc/privates54.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:431b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:431b::1/64", "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config4"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates54.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config4 up\n") f.write("ip addr add 2002:431b::2/64 dev iran5config4\n") f.write("ip -6 route add 2002:431b::1/64 dev iran5config4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config4 mtu {mtu_value}\n" with open("/etc/privates54.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:43{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:431b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v64.sh", 0o755) pings5_v64_service() ## IRAN5 server 5 def runs5_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:441b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/privates55.sh"): os.remove("/etc/privates55.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:441b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:441b::1/64", "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config5"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates55.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config5 up\n") f.write("ip addr add 2002:441b::2/64 dev iran5config5\n") f.write("ip -6 route add 2002:441b::1/64 dev iran5config5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config5 mtu {mtu_value}\n" with open("/etc/privates55.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:44{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:441b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v65.sh", 0o755) pings5_v65_service() ## IRAN6 server 5 def runs5_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:451b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/privates56.sh"): os.remove("/etc/privates56.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:451b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:451b::1/64", "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config6"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates56.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config6 up\n") f.write("ip addr add 2002:451b::2/64 dev iran5config6\n") f.write("ip -6 route add 2002:451b::1/64 dev iran5config6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config6 mtu {mtu_value}\n" with open("/etc/privates56.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:45{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:451b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v66.sh", 0o755) pings5_v66_service() ## IRAN7 server 5 def runs5_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:461b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/privates57.sh"): os.remove("/etc/privates57.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:461b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:461b::1/64", "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config7"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates57.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config7 up\n") f.write("ip addr add 2002:461b::2/64 dev iran5config7\n") f.write("ip -6 route add 2002:461b::1/64 dev iran5config7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config7 mtu {mtu_value}\n" with open("/etc/privates57.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:46{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:461b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v67.sh", 0o755) pings5_v67_service() ## IRAN8 server 5 def runs5_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:471b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/privates58.sh"): os.remove("/etc/privates58.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:471b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:471b::1/64", "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config8"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates58.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config8 up\n") f.write("ip addr add 2002:471b::2/64 dev iran5config8\n") f.write("ip -6 route add 2002:471b::1/64 dev iran5config8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config8 mtu {mtu_value}\n" with open("/etc/privates58.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:47{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:471b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v68.sh", 0o755) pings5_v68_service() ## IRAN9 server 5 def runs5_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:481b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/privates59.sh"): os.remove("/etc/privates59.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:481b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:481b::1/64", "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config9"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates59.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config9 up\n") f.write("ip addr add 2002:481b::2/64 dev iran5config9\n") f.write("ip -6 route add 2002:481b::1/64 dev iran5config9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config9 mtu {mtu_value}\n" with open("/etc/privates59.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:48{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:481b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v69.sh", 0o755) pings5_v69_service() ## IRAN10 server 5 def runs5_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:491b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10s5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/privates510.sh"): os.remove("/etc/privates510.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN Server \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "iran5config10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "iran5config10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:491b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:491b::1/64", "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "iran5config10"], capture_output=True, text=True, ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "iran5config10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/privates510.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add iran5config10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev iran5config10 up\n") f.write("ip addr add 2002:491b::2/64 dev iran5config10\n") f.write("ip -6 route add 2002:491b::1/64 dev iran5config10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev iran5config10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev iran5config10 mtu {mtu_value}\n" with open("/etc/privates510.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") adds5_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runs5_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:49{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:491b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/pings5_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/pings5_v610.sh", 0o755) pings5_v610_service() # iran5gre ##### IRAN gre6 server 5 def iran_ping5(): try: subprocess.run( ["ping", "-c", "2", "2002:841b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran5_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:841b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def gre65_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:84{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre65_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 5 def gre65_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:84{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig65 mtu {mtu_value}\n" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre65_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig65 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:841a::2/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig65 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:841a::1/64 dev azumig65' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig65 mtu {mtu_value}\n" with open("/etc/gre65.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre65_iran(): remote_ip = "2002:841b::1" # kharej ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre65_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def gre65_iransec(): remote_ip = "2002:841b::1" # kharej ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre65_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() ## default route iran server 4 def gre65_iran2(): remote_ip = "2002:841b::1" # kharej ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre65_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def gre65_iran2sec(): remote_ip = "2002:841b::1" # kharej ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre65_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def iran_gre65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre65_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # edit def iran_gre65_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_gre6i5(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre65_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre65_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre65_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran6gre ##### IRAN gre6 server 6 def iran_ping6(): try: subprocess.run( ["ping", "-c", "2", "2002:851b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran6_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:851b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip6.service"]) subprocess.run(["systemctl", "start", "ping_ip6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip6.service"]) def gre66_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig66 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:851a::2/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig66 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:851a::1/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:85{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}" with open("/etc/gre66.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 6:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:851a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 5 def gre66_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig66 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:851a::2/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig66 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:851a::1/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:85{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig66' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig66 mtu {mtu_value}\n" with open("/etc/gre66.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 6:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:851a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping6_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip6.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre66_iran(): remote_ip = "2002:851b::1" # kharej ip local_ip = "2002:851b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre66_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 iran_ping6_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre66_service() gre66_cronjob() ## default route iran server 6 def gre66_iran2(): remote_ip = "2002:851b::1" # kharej ip local_ip = "2002:851b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre66_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 iran_ping6_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre66_service() gre66_cronjob() def iran_gre66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::1/64", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002:851b::1/64 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre66_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre66_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::1/64", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002:851b::1/64 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre66_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran7gre ##### IRAN gre6 server 7 def iran_ping7(): try: subprocess.run( ["ping", "-c", "2", "2002:861b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran7_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:861b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip7.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip7.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip7.service"]) subprocess.run(["systemctl", "start", "ping_ip7.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip7.service"]) def gre67_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig67 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:861a::2/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig67 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:861a::1/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:86{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}" with open("/etc/gre67.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 7:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:861a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 7 def gre67_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig67 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:861a::2/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig67 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:861a::1/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:86{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig67' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig67 mtu {mtu_value}\n" with open("/etc/gre67.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 7:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:861a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping7_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip7.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre67_iran(): remote_ip = "2002:861b::1" # kharej ip local_ip = "2002:861b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre67_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 iran_ping7_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre67_service() gre67_cronjob() ## default route iran server 7 def gre67_iran2(): remote_ip = "2002:861b::1" # kharej ip local_ip = "2002:861b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre67_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 iran_ping7_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre67_service() gre67_cronjob() def iran_gre67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::1/64", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002:861b::1/64 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping7() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre67_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre67_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::1/64", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002:861b::1/64 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping7_script() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre67_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran8gre ##### IRAN gre6 server 8 def iran_ping8(): try: subprocess.run( ["ping", "-c", "2", "2002:871b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran8_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:871b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip8.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip8.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip8.service"]) subprocess.run(["systemctl", "start", "ping_ip8.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip8.service"]) def gre68_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig68 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:871a::2/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig68 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:871a::1/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:87{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}" with open("/etc/gre68.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 8:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:871a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 8 def gre68_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig68 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:871a::2/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig68 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:871a::1/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:87{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig68' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig68 mtu {mtu_value}\n" with open("/etc/gre68.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 8:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:871a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping8_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip8.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre68_iran(): remote_ip = "2002:871b::1" # kharej ip local_ip = "2002:871b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre68_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 iran_ping8_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre68_service() gre68_cronjob() ## default route iran server 8 def gre68_iran2(): remote_ip = "2002:871b::1" # kharej ip local_ip = "2002:871b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre68_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 iran_ping8_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre68_service() gre68_cronjob() def iran_gre68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::1/64", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002:871b::1/64 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping8() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre68_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre68_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::1/64", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002:871b::1/64 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping8_script() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre68_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran9gre ##### IRAN gre6 server 9 def iran_ping9(): try: subprocess.run( ["ping", "-c", "2", "2002:881b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran9_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:881b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip9.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip9.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip9.service"]) subprocess.run(["systemctl", "start", "ping_ip9.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip9.service"]) def gre69_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig69 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:881a::2/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig69 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:881a::1/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:88{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}" with open("/etc/gre69.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 9:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:881a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 9 def gre69_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig69 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:881a::2/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig69 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:881a::1/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:88{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig69' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig69 mtu {mtu_value}\n" with open("/etc/gre69.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 9:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:881a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping9_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip9.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre69_iran(): remote_ip = "2002:881b::1" # kharej ip local_ip = "2002:881b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre69_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:881a::1" # kharejip max_pings = 3 interval = 2 iran_ping9_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre69_service() gre69_cronjob() ## default route iran server 9 def gre69_iran2(): remote_ip = "2002:881b::1" # kharej ip local_ip = "2002:881b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre69_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:881a::1" # kharejip max_pings = 3 interval = 2 iran_ping9_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre69_service() gre69_cronjob() def iran_gre69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::1/64", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002:881b::1/64 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping9() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre69_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre69_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:881b::1/64", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002:881b::1/64 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping9_script() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre69_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # iran10gre ##### IRAN gre6 server 10 def iran_ping10(): try: subprocess.run( ["ping", "-c", "2", "2002:891b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran10_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = "2002:891b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip10.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip10.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip10.service"]) subprocess.run(["systemctl", "start", "ping_ip10.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip10.service"]) def gre610_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig610 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:891a::2/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig610 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:891a::1/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:89{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}" with open("/etc/gre610.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 10:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:891a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ## default route server iran 10 def gre610_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig610 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:891a::2/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig610 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:891a::1/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:89{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig610' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = "ip link set dev azumig610 mtu {mtu_value}\n" with open("/etc/gre610.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 10:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:891a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping10_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip10.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre610_iran(): remote_ip = "2002:891b::1" # kharej ip local_ip = "2002:891b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre610_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:891a::1" # kharejip max_pings = 3 interval = 2 iran_ping10_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre610_service() gre610_cronjob() ## default route iran server 10 def gre610_iran2(): remote_ip = "2002:891b::1" # kharej ip local_ip = "2002:891b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre610_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:891a::1" # kharejip max_pings = 3 interval = 2 iran_ping10_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre610_service() gre610_cronjob() def iran_gre610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::1/64", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002:891b::1/64 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping10() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre610_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # default route def iran2_gre610_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[96m Server\033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:891b::1/64", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002:891b::1/64 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping10_script() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre610_iran2() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ## 10 def priv_mnu_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivateIP \033[92m Multiple Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh_ip() break elif server_type == "2": priv_ir_ip() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def priv_kh_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnu() kharej1_private_menu() break elif server_type == "2": private_reset_rmvmnu() kharej2_private_menu() break elif server_type == "3": private_reset_rmvmnu() kharej3_private_menu() break elif server_type == "4": private_reset_rmvmnu() kharej4_private_menu() break elif server_type == "5": private_reset_rmvmnu() kharej5_private_menu() break elif server_type == "6": private_reset_rmvmnu() kharej6_private_menu() break elif server_type == "7": private_reset_rmvmnu() kharej7_private_menu() break elif server_type == "8": private_reset_rmvmnu() kharej8_private_menu() break elif server_type == "9": private_reset_rmvmnu() kharej9_private_menu() break elif server_type == "10": private_reset_rmvmnu() kharej10_private_menu() break elif server_type == "11": private_reset_rmvmnu() kharej_q() break elif server_type == "0": os.system("clear") priv_mnu_ip() break else: print("Invalid choice.") def kharej_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran{}_private_menu".format(i) globals()[menu_name]() def priv_ir_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnu() iran1_private2_menu() break elif server_type == "2": private_reset_rmvmnu() iran2_private2_menu() break elif server_type == "3": private_reset_rmvmnu() iran3_private2_menu() break elif server_type == "4": private_reset_rmvmnu() iran4_private2_menu() break elif server_type == "5": private_reset_rmvmnu() iran5_private2_menu() break elif server_type == "6": private_reset_rmvmnu() iran_q() break elif server_type == "0": os.system("clear") priv_mnu_ip() break else: print("Invalid choice.") def iran_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "kharej{}_private2_menu".format(i) globals()[menu_name]() ## Kharej 1 def add_cron1_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private1.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private1.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping1(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v61_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v61.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v61.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v61.service"]) subprocess.run(["systemctl", "start", "ping_v61.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v61.service"]) def kharej1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi1"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej1 for iran 1 def kharej1_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi1"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 def add_cron2_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private2.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private2.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping2(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v62_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v62.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v62.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v62.service"]) subprocess.run(["systemctl", "start", "ping_v62.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v62.service"]) def kharej2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi2"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 2 for iran 2 def kharej2_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi2"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # edit def kharej2_private2_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik2(psk) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi2"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 3 def add_cron3_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private3.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private3.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:821b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping3(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v63_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v63.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v63.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v63.service"]) subprocess.run(["systemctl", "start", "ping_v63.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v63.service"]) def kharej3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi3"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 3 for iran 3 def kharej3_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi3"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # edit def kharej3_private2_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik3(psk) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi3"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 4 def add_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private4.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private4.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping4(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v64.service"]) subprocess.run(["systemctl", "start", "ping_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v64.service"]) def kharej4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi4"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 4 for iran 4 def kharej4_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi4"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # edit def kharej4_private2_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik4(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi4"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 5 def add_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private5.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private5.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping5(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v65.service"]) subprocess.run(["systemctl", "start", "ping_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v65.service"]) def kharej5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi5"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 5 for iran 5 def kharej5_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi5"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # edit def kharej5_private2_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik5(psk) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi5"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 6 def add_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private6.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private6.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping6(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v66.service"]) subprocess.run(["systemctl", "start", "ping_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v66.service"]) def kharej6_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi6"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 6 for iran 6 def kharej6_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [6]...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi6"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 def add_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private7.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private7.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping7(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v67.service"]) subprocess.run(["systemctl", "start", "ping_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v67.service"]) def kharej7_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi7"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 7 for iran 7 def kharej7_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [7]...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi7"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 def add_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private8.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private8.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping8(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v68.service"]) subprocess.run(["systemctl", "start", "ping_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v68.service"]) def kharej8_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi8"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 8 for iran 8 def kharej8_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [8]...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi8"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 def add_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private9.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private9.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping9(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:881b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v69.service"]) subprocess.run(["systemctl", "start", "ping_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v69.service"]) def kharej9_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi9"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 9 for iran 9 def kharej9_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [9]...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi9"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 def add_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private10.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private10.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def run_ping10(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:891b::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v610.service"]) subprocess.run(["systemctl", "start", "ping_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v610.service"]) def kharej10_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi10"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 10 for iran 10 def kharej10_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [10]...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi10"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1/64" f.write(f"ip addr add {ip_addr} dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## IRAN1 def run_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:801b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping1_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran1_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi1"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() ## route for iran1_private_menu def iran1_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi1"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi1\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:801b::2\n".format( interface ) with open("/etc/private1.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:80{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() ## IRAN2 def run_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:811b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping2_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran2_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi2"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() ## default route iran2_private_menu def iran2_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi2"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi2\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:811b::2\n".format( interface ) with open("/etc/private2.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:81{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() ## IRAN3 def run_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:821b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping3_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran3_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi3"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() ## default route iran3_private_menu def iran3_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi3"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi3\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:821b::2\n".format( interface ) with open("/etc/private3.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:82{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() ## IRAN4 def run_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:831b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping4_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran4_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi4"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() ##default route iran4_private_menu def iran4_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi4"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi4\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::2\n".format( interface ) with open("/etc/private4.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() ## IRAN5 def run_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:841b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def runsec_ping5_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran5_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi5"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() # default route iran5_private_menu def iran5_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi5"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi5\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:841b::2\n".format( interface ) with open("/etc/private5.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:84{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() ## IRAN6 def run_ping6_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:851b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran6_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi6"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() # default route iran6_private_menu def iran6_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[6]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[6]...\033[0m") if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi6"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi6"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi6"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi6\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:851b::2\n".format( interface ) with open("/etc/private6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:85{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() ## IRAN7 def run_ping7_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:861b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran7_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi7"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() # default route iran7_private_menu def iran7_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[7]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[7]...\033[0m") if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi7"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi7"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi7"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi7\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:861b::2\n".format( interface ) with open("/etc/private7.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:86{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() ## IRAN8 def run_ping8_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:871b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran8_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi8"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() # default route iran8_private_menu def iran8_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[8]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[8]...\033[0m") if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi8"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi8"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi8"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi8\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:871b::2\n".format( interface ) with open("/etc/private8.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:87{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() ## IRAN9 def run_ping9_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:881b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran9_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi9"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() # default route iran9_private_menu def iran9_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[9]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[9]...\033[0m") if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi9"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi9"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi9"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi9\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:881b::2\n".format( interface ) with open("/etc/private9.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:88{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() ## IRAN10 def run_ping10_iran(): try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2002:891b::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran10_private_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi10"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() # default route iran10_private_menu def iran10_private2_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[10]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[10]...\033[0m") if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi10"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input( "\033[93mHow many \033[92madditional private IPs\033[93m do you need? \033[0m" ) ) print("\033[93m─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" result = subprocess.run( ["ip", "addr", "show", "dev", "azumi10"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "addr", "add", ip_addr, "dev", "azumi10"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2/64" f.write(f"ip addr add {ip_addr} dev azumi10\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:891b::2\n".format( interface ) with open("/etc/private10.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:89{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() ##1010 def add_cron6_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private6.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private6.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def add_cron7_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private7.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private7.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def add_cron8_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private8.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private8.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def add_cron9_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private9.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private9.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def add_cron10_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private10.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private10.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_v66_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v66.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v66.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v66.service"]) subprocess.run(["systemctl", "start", "ping_v66.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v66.service"]) def ping_v67_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v67.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v67.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v67.service"]) subprocess.run(["systemctl", "start", "ping_v67.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v67.service"]) def ping_v68_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v68.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v68.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v68.service"]) subprocess.run(["systemctl", "start", "ping_v68.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v68.service"]) def ping_v69_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v69.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v69.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v69.service"]) subprocess.run(["systemctl", "start", "ping_v69.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v69.service"]) def ping_v610_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v610.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v610.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v610.service"]) subprocess.run(["systemctl", "start", "ping_v610.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v610.service"]) def ip6_mnu_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIP6IP6 \033[92m Multiple Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKHAREJ\033[92m[10] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKHAREJ\033[92m[1] \033[93mIRAN\033[92m[10]\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip6_kh_ip() break elif server_type == "2": ip6_ir_ip() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def ip6_kh_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93mIRAN\033[0m") print("0.\033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnu() kharej_ipip61_menu() break elif server_type == "2": ipip6_reset_rmvmnu() kharej_ipip62_menu() break elif server_type == "3": ipip6_reset_rmvmnu() kharej_ipip63_menu() break elif server_type == "4": ipip6_reset_rmvmnu() kharej_ipip64_menu() break elif server_type == "5": ipip6_reset_rmvmnu() kharej_ipip65_menu() break elif server_type == "6": ipip6_reset_rmvmnu() kharej_ipip66_menu() break elif server_type == "7": ipip6_reset_rmvmnu() kharej_ipip67_menu() break elif server_type == "8": ipip6_reset_rmvmnu() kharej_ipip68_menu() break elif server_type == "9": ipip6_reset_rmvmnu() kharej_ipip69_menu() break elif server_type == "10": ipip6_reset_rmvmnu() kharej_ipip610_menu() break elif server_type == "11": ipip6_reset_rmvmnu() kharejip_q() break elif server_type == "0": os.system("clear") ip6_mnu_ip() break else: print("Invalid choice.") def kharejip_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran_ipip6{}_menu".format(i) globals()[menu_name]() def ip6_ir_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 \033[92m[10]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnu() iran2_ipip61_menu() break elif server_type == "2": ipip6_reset_rmvmnu() iran2_ipip62_menu() break elif server_type == "3": ipip6_reset_rmvmnu() iran2_ipip63_menu() break elif server_type == "4": ipip6_reset_rmvmnu() iran2_ipip64_menu() break elif server_type == "5": ipip6_reset_rmvmnu() iran2_ipip65_menu() break elif server_type == "6": ipip6_reset_rmvmnu() iran2_ipip66_menu() break elif server_type == "7": ipip6_reset_rmvmnu() iran2_ipip67_menu() break elif server_type == "8": ipip6_reset_rmvmnu() iran2_ipip68_menu() break elif server_type == "9": ipip6_reset_rmvmnu() iran2_ipip69_menu() break elif server_type == "10": ipip6_reset_rmvmnu() iran2_ipip610_menu() break elif server_type == "11": ipip6_reset_rmvmnu() iranip_q() break elif server_type == "0": os.system("clear") ip6_mnu_ip() break else: print("Invalid choice.") def iranip_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "kharej2_ipip6{}_menu".format(i) globals()[menu_name]() def run_ping1(): try: subprocess.run( ["ping", "-c", "2", "2002:801b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej1_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:801b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip1_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def ipip61_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a020::1/64 dev azumip1' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip1 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip1' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a02{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip1' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}\n" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a020::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip61_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a020::1/64 dev azumip1' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip1 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a020::2/64 dev azumip1' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}\n" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a020::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip1_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip1.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip1.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip1_kharej(): remote_ip = "2002:801b::2" # iran-ip local_ip = "2002:801b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip61_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a020::2" # iranip max_pings = 3 interval = 2 create_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip1_kharejsec(): remote_ip = "2002:801b::2" # iran-ip local_ip = "2002:801b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip61_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a020::2" # iranip max_pings = 3 interval = 2 create_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ## kharej 1 for iran 1 def kharej2_ipip61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##kharej2 def run_ping2(): try: subprocess.run( ["ping", "-c", "2", "2002:811b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej2_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:811b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip2_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def ipip62_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a120::1/64 dev azumip2' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip2 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip2' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a12{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip2' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a120::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip62_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a120::1/64 dev azumip2' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip2 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a120::2/64 dev azumip2' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a120::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip2_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip2.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip2.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip2_kharej(): remote_ip = "2002:811b::2" # iran-ip local_ip = "2002:811b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip62_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a120::2" # iranip max_pings = 3 interval = 2 create_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip2_kharejsec(): remote_ip = "2002:811b::2" # iran-ip local_ip = "2002:811b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip62_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a120::2" # iranip max_pings = 3 interval = 2 create_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 2 for iran 2 def kharej2_ipip62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##kharej3 def run_ping3(): try: subprocess.run( ["ping", "-c", "2", "2002:821b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej3_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:821b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip3_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def ipip63_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a220::1/64 dev azumip3' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip3 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip3' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip3' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a220::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip63_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a220::1/64 dev azumip3' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip3 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a020::2/64 dev azumip3' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a220::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip3_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip3.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip3.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip3_kharej(): remote_ip = "2002:821b::2" # iran-ip local_ip = "2002:821b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip63_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::2" # iranip max_pings = 3 interval = 2 create_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip3_kharejsec(): remote_ip = "2002:821b::2" # iran-ip local_ip = "2002:821b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip63_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a220::2" # iranip max_pings = 3 interval = 2 create_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 3 for iran 3 def kharej2_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##kharej3 def run_ping3(): try: subprocess.run( ["ping", "-c", "2", "2002:821b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej3_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:821b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip3_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def ipip63_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a220::1/64 dev azumip3' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip3 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip3' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip3' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a220::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip3_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip3.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip3.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip3_kharej(): remote_ip = "2002:821b::2" # iran-ip local_ip = "2002:821b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip63_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::2" # iranip max_pings = 3 interval = 2 create_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 3 for iran 3 def kharej2_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 4 def run_ping4(): try: subprocess.run( ["ping", "-c", "2", "2002:831b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej4_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip4_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def ipip64_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip4.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip4 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a320::1/64 dev azumip4' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip4 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip4' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a32{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip4' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip4 mtu {mtu_value}\n" with open("/etc/ipip4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a320::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip64_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip4.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip4 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a320::1/64 dev azumip4' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip4 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a320::2/64 dev azumip4' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip4 mtu {mtu_value}\n" with open("/etc/ipip4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a320::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip4_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip4.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip4.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip4_kharej(): remote_ip = "2002:831b::2" # iran-ip local_ip = "2002:831b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip64_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a320::2" # iranip max_pings = 3 interval = 2 create_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip4_service() ipip4_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip4_kharejsec(): remote_ip = "2002:831b::2" # iran-ip local_ip = "2002:831b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip64_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a320::2" # iranip max_pings = 3 interval = 2 create_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip4_service() ipip4_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 4 for iran 4 def kharej2_ipip64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 5 def run_ping5(): try: subprocess.run( ["ping", "-c", "2", "2002:841b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej5_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:841b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip5_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def ipip65_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip5.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip5 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a420::1/64 dev azumip5' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip5 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip5' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a42{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip5' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip5 mtu {mtu_value}\n" with open("/etc/ipip5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a420::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip65_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip5.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip5 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a420::1/64 dev azumip5' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip5 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a420::2/64 dev azumip5' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip5 mtu {mtu_value}\n" with open("/etc/ipip5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a420::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip5_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip5.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip5.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip5_kharej(): remote_ip = "2002:841b::2" # iran-ip local_ip = "2002:841b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip65_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a420::2" # iranip max_pings = 3 interval = 2 create_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip5_service() ipip5_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip5_kharejsec(): remote_ip = "2002:841b::2" # iran-ip local_ip = "2002:841b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip65_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a420::2" # iranip max_pings = 3 interval = 2 create_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip5_service() ipip5_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 5 for iran 5 def kharej2_ipip65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 6 def run_ping6(): try: subprocess.run( ["ping", "-c", "2", "2002:851b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej6_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:851b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip6.service"]) subprocess.run(["systemctl", "start", "ping_ip6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip6.service"]) def ipip66_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip6 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a520::1/64 dev azumip6' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a52{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}\n" with open("/etc/ipip6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 6:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a520::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip6_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip6.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip6.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping6_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip6.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip6_kharej(): remote_ip = "2002:851b::2" # iran-ip local_ip = "2002:851b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip66_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a520::2" # iranip max_pings = 3 interval = 2 create_ping6_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip6_service() ipip6_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[6]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip6_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 6 for iran 6 def kharej2_ipip66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[6]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping6() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip6_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 7 def run_ping7(): try: subprocess.run( ["ping", "-c", "2", "2002:861b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej7_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:861b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip7_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip7.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip7.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip7.service"]) subprocess.run(["systemctl", "start", "ping_ip7.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip7.service"]) def ipip67_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip7.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip7 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a620::1/64 dev azumip7' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip7 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip7' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a62{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip7' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip7 mtu {mtu_value}\n" with open("/etc/ipip7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 7:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a620::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip7_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip7.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip7.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping7_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip7.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip7_kharej(): remote_ip = "2002:861b::2" # iran-ip local_ip = "2002:861b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip67_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a620::2" # iranip max_pings = 3 interval = 2 create_ping7_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip7_service() ipip7_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[7]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip7_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 7 for iran 7 def kharej2_ipip67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[7]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping7() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip7_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 8 def run_ping8(): try: subprocess.run( ["ping", "-c", "2", "2002:871b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej8_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:871b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip8_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip8.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip8.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip8.service"]) subprocess.run(["systemctl", "start", "ping_ip8.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip8.service"]) def ipip68_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip8.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip8 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a720::1/64 dev azumip8' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip8 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip8' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a72{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip8' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip8 mtu {mtu_value}\n" with open("/etc/ipip8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 8:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a720::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip8_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip8.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip8.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping8_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip8.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip8_kharej(): remote_ip = "2002:871b::2" # iran-ip local_ip = "2002:871b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip68_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a720::2" # iranip max_pings = 3 interval = 2 create_ping8_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip8_service() ipip8_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[8]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip8_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 8 for iran 8 def kharej2_ipip68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[8]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping8() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip8_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 9 def run_ping9(): try: subprocess.run( ["ping", "-c", "2", "2002:881b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej9_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:881b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip9_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip9.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip9.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip9.service"]) subprocess.run(["systemctl", "start", "ping_ip9.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip9.service"]) def ipip69_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip9.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip9 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a820::1/64 dev azumip9' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip9 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip9' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a82{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip9' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip9 mtu {mtu_value}\n" with open("/etc/ipip9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 9:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a820::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip9_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip9.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip9.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping9_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip9.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip9_kharej(): remote_ip = "2002:881b::2" # iran-ip local_ip = "2002:881b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip69_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a820::2" # iranip max_pings = 3 interval = 2 create_ping9_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip9_service() ipip9_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[9]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip9_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 9 for iran 9 def kharej2_ipip69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[9]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::1/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping9() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:881b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip9_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 10 def run_ping10(): try: subprocess.run( ["ping", "-c", "2", "2002:891b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_kharej10_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:891b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 kharej def ping_ipip10_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip10.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip10.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip10.service"]) subprocess.run(["systemctl", "start", "ping_ip10.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip10.service"]) def ipip610_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip10.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip10 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a920::1/64 dev azumip10' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip10 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip10' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a92{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip10' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip10 mtu {mtu_value}\n" with open("/etc/ipip10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses \033[92mServer 10:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a920::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip10_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip10.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip10.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping10_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip10.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip10_kharej(): remote_ip = "2002:891b::2" # iran-ip local_ip = "2002:891b::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip610_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a920::2" # iranip max_pings = 3 interval = 2 create_ping10_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip10_service() ipip10_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def kharej_ipip610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[10]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip10_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 10 for iran 10 def kharej2_ipip610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[10]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::1/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping10() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:891b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip10_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 1 def iran_ping1(): try: subprocess.run( ["ping", "-c", "2", "2002:801b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran1_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:801b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran def iran_ipip1_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip1.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip1.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip1.service"]) subprocess.run(["systemctl", "start", "ping_ip1.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip1.service"]) def ipip61_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a020::2/64 dev azumip1\n") f.write("ip link set azumip1 up\n") f.write("ip -6 route add 2002::/16 dev azumip1\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a02{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip1\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a020::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip61_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a020::2/64 dev azumip1\n") f.write("ip link set azumip1 up\n") f.write("ip -6 route add 2002:0db8:1234:a020::1/64 dev azumip1\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a020::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # default route ipip_iran1 def ipip61_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a020::2/64 dev azumip1\n") f.write("ip link set azumip1 up\n") f.write("ip -6 route add 2002::/16 dev azumip1\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a02{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip1\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a020::2\n".format( interface ) with open("/etc/ipip1.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}\n" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a020::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip61_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip1.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip1 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a020::2/64 dev azumip1\n") f.write("ip link set azumip1 up\n") f.write("ip -6 route add 2002:0db8:1234:a020::1/64 dev azumip1\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a020::2\n".format( interface ) with open("/etc/ipip1.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip1 mtu {mtu_value}\n" with open("/etc/ipip1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 1:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a020::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip1_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip1.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip1.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping1_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip1.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip1_iran(): remote_ip = "2002:801b::1" # kharej-ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip61_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a020::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip1_iransec(): remote_ip = "2002:801b::1" # kharej-ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip61_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a020::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # default route iran 1 def ipip1_iran2(): remote_ip = "2002:801b::1" # kharej-ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip61_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a020::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip1_iran2sec(): remote_ip = "2002:801b::1" # kharej-ip local_ip = "2002:801b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip61_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a020::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip1_service() ipip1_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 1 menu def iran2_ipip61_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_iran2() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 2 def iran_ping2(): try: subprocess.run( ["ping", "-c", "2", "2002:811b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran2_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:811b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran2 def iran_ipip2_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip2.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip2.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip2.service"]) subprocess.run(["systemctl", "start", "ping_ip2.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip2.service"]) def ipip62_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a120::2/64 dev azumip2\n") f.write("ip link set azumip2 up\n") f.write("ip -6 route add 2002::/16 dev azumip2\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a12{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip2\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a120::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip62_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a120::2/64 dev azumip2\n") f.write("ip link set azumip2 up\n") f.write("ip -6 route add 2002:0db8:1234:a120::1/64 dev azumip2\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a120::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##defaul route ipip iran2 def ipip62_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a120::2/64 dev azumip2\n") f.write("ip link set azumip2 up\n") f.write("ip -6 route add 2002::/16 dev azumip2\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a12{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip2\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a120::2\n".format( interface ) with open("/etc/ipip2.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a120::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip62_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip2.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip2 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a120::2/64 dev azumip2\n") f.write("ip link set azumip2 up\n") f.write("ip -6 route add 2002:0db8:1234:a120::1/64 dev azumip2\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a120::2\n".format( interface ) with open("/etc/ipip2.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip2 mtu {mtu_value}\n" with open("/etc/ipip2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 2:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a120::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip2_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip2.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip2.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping2_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip2.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip2_iran(): remote_ip = "2002:811b::1" # kharej-ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip62_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a120::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip2_iransec(): remote_ip = "2002:811b::1" # kharej-ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip62_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a120::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # default route iran server 2 def ipip2_iran2(): remote_ip = "2002:811b::1" # kharej-ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip62_iran2_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a120::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip2_iran2sec(): remote_ip = "2002:811b::1" # kharej-ip local_ip = "2002:811b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip62_iran2_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a120::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip2_service() ipip2_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 2 menu def iran2_ipip62_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_iran2() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 3 def iran_ping3(): try: subprocess.run( ["ping", "-c", "2", "2002:821b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran3_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:821b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran3 def iran_ipip3_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip3.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip3.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip3.service"]) subprocess.run(["systemctl", "start", "ping_ip3.service"]) subprocess.run(["systemctl", "restart", "ping_ip3.service"]) def ipip63_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip3\n") f.write("ip link set azumip3 up\n") f.write("ip -6 route add 2002::/16 dev azumip3\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip3\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip63_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip3\n") f.write("ip link set azumip3 up\n") f.write("ip -6 route add 2002:0db8:1234:a220::1/64 dev azumip3\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##default route ipip iran3 def ipip63_iran2_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip3\n") f.write("ip link set azumip3 up\n") f.write("ip -6 route add 2002::/16 dev azumip3\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip3\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::2\n".format( interface ) with open("/etc/ipip3.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip63_iran2_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip3.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip3 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip3\n") f.write("ip link set azumip3 up\n") f.write("ip -6 route add 2002:0db8:1234:a220::1/64 dev azumip3\n") subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::2\n".format( interface ) with open("/etc/ipip3.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip3 mtu {mtu_value}\n" with open("/etc/ipip3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 3:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip3_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip3.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip3.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping3_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip3.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip3_iran(): remote_ip = "2002:821b::1" # kharej-ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip63_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip3_iransec(): remote_ip = "2002:821b::1" # kharej-ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip63_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # default route iran server 2 def ipip3_iran2(): remote_ip = "2002:821b::1" # kharej-ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip63_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip3_iran2sec(): remote_ip = "2002:821b::1" # kharej-ip local_ip = "2002:821b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip63_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip3_service() ipip3_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 3 menu def iran2_ipip63_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_iran2() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 4 def iran_ping4(): try: subprocess.run( ["ping", "-c", "2", "2002:831b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran4_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:831b::2/64" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran4 def iran_ipip4_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def ipip64_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip4.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip4 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a320::2/64 dev azumip4\n") f.write("ip link set azumip4 up\n") f.write("ip -6 route add 2002::/16 dev azumip4\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a32{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip4\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip4 mtu {mtu_value}" with open("/etc/ipip4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a320::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip64_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip4.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip4 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a320::2/64 dev azumip4\n") f.write("ip link set azumip4 up\n") f.write("ip -6 route add 2002:0db8:1234:a320::1/64 dev azumip4\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip4 mtu {mtu_value}" with open("/etc/ipip4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 4:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a320::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip4_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip4.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip4.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping4_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip4.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip4_iran(): remote_ip = "2002:831b::1" # kharej-ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip64_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a320::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip4_service() ipip4_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip4_iransec(): remote_ip = "2002:831b::1" # kharej-ip local_ip = "2002:831b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip64_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a320::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip4_service() ipip4_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip64_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 4 menu def iran2_ipip64_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 5 def iran_ping5(): try: subprocess.run( ["ping", "-c", "2", "2002:841b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran5_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:841b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran5 def iran_ipip5_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) def ipip65_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip5.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip5 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a420::2/64 dev azumip5\n") f.write("ip link set azumip5 up\n") f.write("ip -6 route add 2002::/16 dev azumip5\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a42{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip5\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip5 mtu {mtu_value}" with open("/etc/ipip5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a420::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip65_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip5.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip5 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a420::2/64 dev azumip5\n") f.write("ip link set azumip5 up\n") f.write("ip -6 route add 2002:0db8:1234:a420::1/64 dev azumip5\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip5 mtu {mtu_value}" with open("/etc/ipip5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 5:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a420::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip5_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip5.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip5.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping5_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip5.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip5_iran(): remote_ip = "2002:841b::1" # kharej-ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip65_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a420::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip5_service() ipip5_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip5_iransec(): remote_ip = "2002:841b::1" # kharej-ip local_ip = "2002:841b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip65_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a420::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip5_service() ipip5_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip65_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 5 menu def iran2_ipip65_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 6 def iran_ping6(): try: subprocess.run( ["ping", "-c", "2", "2002:851b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran6_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:851b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran6 def iran_ipip6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip6.service"]) subprocess.run(["systemctl", "start", "ping_ip6.service"]) subprocess.run(["systemctl", "restart", "ping_ip6.service"]) def ipip66_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip6.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip6 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a520::2/64 dev azumip6\n") f.write("ip link set azumip6 up\n") f.write("ip -6 route add 2002::/16 dev azumip6\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a52{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip6\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip6 mtu {mtu_value}" with open("/etc/ipip6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 6:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a520::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip6_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip6.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip6.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping6_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip6.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip6_iran(): remote_ip = "2002:851b::1" # kharej-ip local_ip = "2002:851b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip66_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a520::1" # kharejip max_pings = 3 interval = 2 iran_ping6_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip6_service() ipip6_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip66_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[6]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping6() script_content1 = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip6_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 6 menu def iran2_ipip66_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[6]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi6\n") f.write("ip -6 route add 2002::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping6() script_content1 = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip6_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 7 def iran_ping7(): try: subprocess.run( ["ping", "-c", "2", "2002:861b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran7_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:861b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran7 def iran_ipip7_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip7.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip7.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip7.service"]) subprocess.run(["systemctl", "start", "ping_ip7.service"]) subprocess.run(["systemctl", "restart", "ping_ip7.service"]) def ipip67_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip7.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip7 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a620::2/64 dev azumip7\n") f.write("ip link set azumip7 up\n") f.write("ip -6 route add 2002::/16 dev azumip7\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a62{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip7\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip7 mtu {mtu_value}" with open("/etc/ipip7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 7:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a620::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip7_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip7.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip7.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping7_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip7.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip7_iran(): remote_ip = "2002:861b::1" # kharej-ip local_ip = "2002:861b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip67_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a620::1" # kharejip max_pings = 3 interval = 2 iran_ping7_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip7_service() ipip7_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip67_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[7]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping7() script_content1 = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip7_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 7 menu def iran2_ipip67_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[7]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi7\n") f.write("ip -6 route add 2002::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping7() script_content1 = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip7_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 8 def iran_ping8(): try: subprocess.run( ["ping", "-c", "2", "2002:871b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran8_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:871b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran8 def iran_ipip8_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip8.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip8.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip8.service"]) subprocess.run(["systemctl", "start", "ping_ip8.service"]) subprocess.run(["systemctl", "restart", "ping_ip8.service"]) def ipip68_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip8.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip8 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a720::2/64 dev azumip8\n") f.write("ip link set azumip8 up\n") f.write("ip -6 route add 2002::/16 dev azumip8\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a72{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip8\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip8 mtu {mtu_value}" with open("/etc/ipip8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 8:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a720::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip8_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip8.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip8.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping8_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip8.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip8_iran(): remote_ip = "2002:871b::1" # kharej-ip local_ip = "2002:871b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip68_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a720::1" # kharejip max_pings = 3 interval = 2 iran_ping8_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip8_service() ipip8_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip68_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[8]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping8() script_content1 = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip8_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 8 menu def iran2_ipip68_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[8]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi8\n") f.write("ip -6 route add 2002::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping8() script_content1 = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip8_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 9 def iran_ping9(): try: subprocess.run( ["ping", "-c", "2", "2002:881b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran9_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:881b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran9 def iran_ipip9_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip9.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip9.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip9.service"]) subprocess.run(["systemctl", "start", "ping_ip9.service"]) subprocess.run(["systemctl", "restart", "ping_ip9.service"]) def ipip69_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip9.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip9 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a820::2/64 dev azumip9\n") f.write("ip link set azumip9 up\n") f.write("ip -6 route add 2002::/16 dev azumip9\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a82{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip9\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip9 mtu {mtu_value}" with open("/etc/ipip9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 9:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a820::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip9_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip9.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip9.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping9_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip9.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip9_iran(): remote_ip = "2002:881b::1" # kharej-ip local_ip = "2002:881b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip69_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a820::1" # kharejip max_pings = 3 interval = 2 iran_ping9_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip9_service() ipip9_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip69_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[9]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping9() script_content1 = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip9_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 9 menu def iran2_ipip69_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[9]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:881b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add 2002:881b::2/64 dev azumi9\n") f.write("ip -6 route add 2002::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping9() script_content1 = """#!/bin/bash ip_address="2002:881b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip9_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 10 def iran_ping10(): try: subprocess.run( ["ping", "-c", "2", "2002:891b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran10_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "2002:891b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran10 def iran_ipip10_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip10.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip10.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip10.service"]) subprocess.run(["systemctl", "start", "ping_ip10.service"]) subprocess.run(["systemctl", "restart", "ping_ip10.service"]) def ipip610_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip10.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip10 mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a920::2/64 dev azumip10\n") f.write("ip link set azumip10 up\n") f.write("ip -6 route add 2002::/16 dev azumip10\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a92{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip10\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip10 mtu {mtu_value}" with open("/etc/ipip10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses \033[92mServer 10:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a920::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip10_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip10.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip10.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping10_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip10.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip10_iran(): remote_ip = "2002:891b::1" # kharej-ip local_ip = "2002:891b::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip610_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a920::1" # kharejip max_pings = 3 interval = 2 iran_ping10_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip10_service() ipip10_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip610_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[10]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping10() script_content1 = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip10_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 10 menu def iran2_ipip610_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mServer\033[93m\033[96m[10]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:891b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add 2002:891b::2/64 dev azumi10\n") f.write("ip -6 route add 2002::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping10() script_content1 = """#!/bin/bash ip_address="2002:891b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip10_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # 11 def config_ipipk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip1 left=%defaultroute leftsubnet=2002:0db8:1234:a020::1/64 leftid=2002:0db8:1234:a020::1 right=2002:0db8:1234:a020::2 rightsubnet=2002:0db8:1234:a020::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a020::2 2002:0db8:1234:a020::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipk2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip2 left=%defaultroute leftsubnet=2002:0db8:1234:a120::1/64 leftid=2002:0db8:1234:a120::1 right=2002:0db8:1234:a120::2 rightsubnet=2002:0db8:1234:a120::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a120::2 2002:0db8:1234:a120::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipk3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip3 left=%defaultroute leftsubnet=2002:0db8:1234:a220::1/64 leftid=2002:0db8:1234:a220::1 right=2002:0db8:1234:a220::2 rightsubnet=2002:0db8:1234:a220::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a220::2 2002:0db8:1234:a220::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipk4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip4 left=%defaultroute leftsubnet=2002:0db8:1234:a320::1/64 leftid=2002:0db8:1234:a320::1 right=2002:0db8:1234:a320::2 rightsubnet=2002:0db8:1234:a320::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a320::2 2002:0db8:1234:a320::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipk5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip5 left=%defaultroute leftsubnet=2002:0db8:1234:a420::1/64 leftid=2002:0db8:1234:a420::1 right=2002:0db8:1234:a420::2 rightsubnet=2002:0db8:1234:a420::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a420::2 2002:0db8:1234:a420::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip1 left=%defaultroute leftsubnet=2002:0db8:1234:a020::2/64 leftid=2002:0db8:1234:a020::2 right=2002:0db8:1234:a020::1 rightsubnet=2002:0db8:1234:a020::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a020::1 2002:0db8:1234:a020::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip2 left=%defaultroute leftsubnet=2002:0db8:1234:a120::2/64 leftid=2002:0db8:1234:a120::2 right=2002:0db8:1234:a120::1 rightsubnet=2002:0db8:1234:a120::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:0db8:1234:a120::1 2002:0db8:1234:a120::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipip3 left=%defaultroute leftsubnet=2002:0db8:1234:a220::2/64 leftid=2002:0db8:1234:a220::2 right=2002:0db8:1234:a220::1 rightsubnet=2002:0db8:1234:a220::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a220::1 2002:0db8:1234:a220::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan4 left=%defaultroute leftsubnet=2002:0db8:1234:a320::2/64 leftid=2002:0db8:1234:a320::2 right=2002:0db8:1234:a320::1 rightsubnet=2002:0db8:1234:a320::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a320::1 2002:0db8:1234:a320::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2002:0db8:1234:a420::2/64 leftid=2002:0db8:1234:a420::2 right=2002:0db8:1234:a420::1 rightsubnet=2002:0db8:1234:a420::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a420::1 2002:0db8:1234:a420::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipk(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn ipip{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:0db8:1234:a{i+0}20::1/64\n") f.write(f" leftid=2002:0db8:1234:a{i+0}20::1\n") f.write(f" right=2002:0db8:1234:a{i+0}20::2\n") f.write(f" rightsubnet=2002:0db8:1234:a{i+0}20::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write( f'2002:0db8:1234:a{i+0}20::2 2002:0db8:1234:a{i+0}20::1 : PSK "{psk}"\n' ) subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipipi(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn ipip{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:0db8:1234:a{i+0}20::2/64\n") f.write(f" leftid=2002:0db8:1234:a{i+0}20::2\n") f.write(f" right=2002:0db8:1234:a{i+0}20::1\n") f.write(f" rightsubnet=2002:0db8:1234:a{i+0}20::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write( f'2002:0db8:1234:a{i+0}20::1 2002:0db8:1234:a{i+0}20::2 : PSK "{psk}"\n' ) subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def ip6_mnu_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSec \033[92m Multiple Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKHAREJ\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKHAREJ\033[92m[1] \033[93mIRAN\033[92m[5]\033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ip6_kh_ipsec() break elif server_type == "2": ip6_ir_ipsec() break elif server_type == "3": choose_reset2() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def ip6_kh_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSec \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_ipip61sec_menu() restart_forced_strongazumi() break elif server_type == "2": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_ipip62sec_menu() restart_forced_strongazumi() break elif server_type == "3": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_ipip63sec_menu() restart_forced_strongazumi() break elif server_type == "4": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_ipip64sec_menu() restart_forced_strongazumi() break elif server_type == "5": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej_ipip65sec_menu() restart_forced_strongazumi() break elif server_type == "6": ipip6_reset_rmvmnu() enable_reset_ipsec() kharejip_qsec() break elif server_type == "0": os.system("clear") ip6_mnu_ipsec() break else: print("Invalid choice.") def kharejip_qsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "iran_ipip6{}sec_menu".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def kharejip_qsecedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi(psk, num_servers) # edit2 def kharejip_qsecedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now\033[93m?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipipi(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def ip6_ir_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mIP6IP6 + IPSec \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_ipip61sec_menu() restart_forced_strongazumi() break elif server_type == "2": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_ipip62sec_menu() restart_forced_strongazumi() break elif server_type == "3": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_ipip63sec_menu() restart_forced_strongazumi() break elif server_type == "4": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_ipip64sec_menu() restart_forced_strongazumi() break elif server_type == "5": ipip6_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_ipip65sec_menu() restart_forced_strongazumi() break elif server_type == "6": ipip6_reset_rmvmnu() enable_reset_ipsec() iranip_qsec() break elif server_type == "0": os.system("clear") ip6_mnu_ipsec() break else: print("Invalid choice.") def iranip_qsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "kharej2_ipip6{}sec_menu".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def iranip_qsecedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk(psk, num_servers) restart_forced_strongazumi() # edit2 def iranip_qsecedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now\033[93m?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipipk(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def kharej_ipip61sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk1(psk) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ## kharej 1 for iran 1 def kharej2_ipip61sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def kharej2_ipip61sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 \033[92mKharej\033[93m server\033[92m[1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk1(psk) initial_ip = "2002:801b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping1() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:801b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##kharej2 def kharej_ipip62sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk2(psk) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 2 for iran 2 def kharej2_ipip62sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def kharej2_ipip62sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk2(psk) initial_ip = "2002:811b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping2() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:811b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##kharej3 def kharej_ipip63sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk3(psk) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 3 for iran 3 def kharej2_ipip63sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def kharej2_ipip63sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk3(psk) initial_ip = "2002:821b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping3() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:821b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 4 def kharej_ipip64sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk4(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 4 for iran 4 def kharej2_ipip64sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def kharej2_ipip64sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk4(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping4() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 5 def kharej_ipip65sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk5(psk) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # kharej 5 for iran 5 def kharej2_ipip65sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def kharej2_ipip65sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IP6IP6 + IPSec \033[92mKharej\033[93m server\033[92m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej \033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipk5(psk) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping5() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 server 1 def iran_ipip61sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def iran_ipip61sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi1(psk) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 1 menu def iran2_ipip61sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[1]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi1(psk) initial_ip = "2002:801b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:801b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:801b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:801b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping1() script_content1 = """#!/bin/bash ip_address="2002:801b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip1_iran2sec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def iran_ipip62sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def iran_ipip62sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi2(psk) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 2 menu def iran2_ipip62sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[2]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi2(psk) initial_ip = "2002:811b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:811b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:811b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:811b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping2() script_content1 = """#!/bin/bash ip_address="2002:811b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip2_iran2sec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def iran_ipip63sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def iran_ipip63sec_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi3(psk) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 3 menu def iran2_ipip63sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[3]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi3(psk) initial_ip = "2002:821b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:821b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:821b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:821b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping3() script_content1 = """#!/bin/bash ip_address="2002:821b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip3_iran2sec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def iran_ipip64sec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def iran_ipip64sec_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi4(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 4 menu def iran2_ipip64sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[4]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi4(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping4() script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip4_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def iran_ipip65sec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") # edit def iran_ipip65sec_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi5(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##default route iran server 5 menu def iran2_ipip65sec_menu(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 + IPSec \033[92mServer\033[93m\033[96m[5]\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipipi5(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping5() script_content1 = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip5_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ## 12 ## private ipsec def config_prik1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn private1 left=%defaultroute leftsubnet=2002:831b::1/64 leftid=2002:831b::1 right=2002:831b::2 rightsubnet=2002:831b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831b::2 2002:831b::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prik2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private2 left=%defaultroute leftsubnet=2002:841b::1/64 leftid=2002:841b::1 right=2002:841b::2 rightsubnet=2002:841b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:841b::2 2002:841b::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prik3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private3 left=%defaultroute leftsubnet=2002:851b::1/64 leftid=2002:851b::1 right=2002:851b::2 rightsubnet=2002:851b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:851b::2 2002:851b::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prik4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private4 left=%defaultroute leftsubnet=2002:861b::1/64 leftid=2002:861b::1 right=2002:861b::2 rightsubnet=2002:861b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:861b::2 2002:861b::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prik5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private5 left=%defaultroute leftsubnet=2002:871b::1/64 leftid=2002:871b::1 right=2002:871b::2 rightsubnet=2002:871b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:871b::2 2002:871b::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prii1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private1 left=%defaultroute leftsubnet=2002:831b::2/64 leftid=2002:831b::2 right=2002:831b::1 rightsubnet=2002:831b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:831b::1 2002:831b::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prii2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn private2 left=%defaultroute leftsubnet=2002:841b::2/64 leftid=2002:841b::2 right=2002:841b::1 rightsubnet=2002:841b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:841b::1 2002:841b::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prii3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn private3 left=%defaultroute leftsubnet=2002:851b::2/64 leftid=2002:851b::2 right=2002:851b::1 rightsubnet=2002:851b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:851b::1 2002:851b::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prii4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn private4 left=%defaultroute leftsubnet=2002:861b::2/64 leftid=2002:861b::2 right=2002:861b::1 rightsubnet=2002:861b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:861b::1 2002:861b::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_prii5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn private5 left=%defaultroute leftsubnet=2002:871b::2/64 leftid=2002:871b::2 right=2002:871b::1 rightsubnet=2002:871b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:871b::1 2002:871b::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_privatek(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn private{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+3}1b::1/64\n") f.write(f" leftid=2002:8{i+3}1b::1\n") f.write(f" right=2002:8{i+3}1b::2\n") f.write(f" rightsubnet=2002:8{i+3}1b::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+3}1b::2 2002:8{i+3}1b::1 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_privatei(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn private{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+3}1b::2/64\n") f.write(f" leftid=2002:8{i+3}1b::2\n") f.write(f" right=2002:8{i+3}1b::1\n") f.write(f" rightsubnet=2002:8{i+3}1b::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+3}1b::1 2002:8{i+3}1b::2 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def priv_mnu_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivateIP + IPsec \033[92m Multiple Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[96mKharej\033[92m[5] \033[93mIRAN\033[92m[1]\033[0m") print("2. \033[96mKharej\033[92m[1] \033[93mIRAN\033[92m[5] \033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh_ipsec() break elif server_type == "2": priv_ir_ipsec() break elif server_type == "3": choose_reset2() break elif server_type == "0": os.system("clear") multiserver_mnu() break else: print("Invalid choice.") def priv_kh_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP + IPsec \033[92m[5]Kharej\033[96m [1]IRAN\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej1_private_ipsec() restart_forced_strongazumi() break elif server_type == "2": private_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej2_private_ipsec() restart_forced_strongazumi() break elif server_type == "3": private_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej3_private_ipsec() restart_forced_strongazumi() break elif server_type == "4": private_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej4_private_ipsec() restart_forced_strongazumi() break elif server_type == "5": private_reset_rmvmnu() remove_config() enable_reset_ipsec() kharej5_private_ipsec() restart_forced_strongazumi() break elif server_type == "6": private_reset_rmvmnu() enable_reset_ipsec() kharej_qpri_ipsec() break elif server_type == "0": os.system("clear") priv_mnu_ipsec() break else: print("Invalid choice.") def kharej_qpri_ipsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_privatei(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "iran{}_private_ipsec".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def kharej_qpri_ipsecedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mkharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_privatei(psk, num_servers) restart_forced_strongazumi() # edit2 def kharej_qpri_ipsecedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mkharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m: \033[0m") config_privatei(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def priv_ir_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mPrivate IP + IPsec \033[92m[5]IRAN\033[96m [1]Kharej\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnu() remove_config() enable_reset_ipsec() iran1_private2_ipsec() restart_forced_strongazumi() break elif server_type == "2": private_reset_rmvmnu() remove_config() enable_reset_ipsec() iran2_private2_ipsec() restart_forced_strongazumi() break elif server_type == "3": private_reset_rmvmnu() remove_config() enable_reset_ipsec() iran3_private2_ipsec() restart_forced_strongazumi() break elif server_type == "4": private_reset_rmvmnu() remove_config() enable_reset_ipsec() iran4_private2_ipsec() restart_forced_strongazumi() break elif server_type == "5": private_reset_rmvmnu() remove_config() enable_reset_ipsec() iran5_private2_ipsec() restart_forced_strongazumi() break elif server_type == "6": private_reset_rmvmnu() enable_reset_ipsec() iran_qpri_ipsec() break elif server_type == "0": os.system("clear") priv_mnu_ipsec() break else: print("Invalid choice.") def iran_qpri_ipsec(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_privatek(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "kharej{}_private2_ipsec".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def iran_qpri_ipsecedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_privatek(psk, num_servers) restart_forced_strongazumi() # edit2 def iran_qpri_ipsecedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_privatek(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification( "\033[93mUse systemctl restart strong-azumi1 in kharej servers as well \033[0m" ) restart_forced_strongazumi() def kharej1_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik1(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej1 for iran 1 def kharej1_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi1\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # edit def kharej1_private2_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [1]...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik1(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::1/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() print("\033[92mKharej Server Configuration Completed!\033[0m") ## Kharej 2 def kharej2_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik2(psk) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:841b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 2 for iran 2 def kharej2_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [2]...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:841b::1/64 dev azumi2\n") f.write("ip -6 route add 2002:841b::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping2() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:841b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:841b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharej3_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik3(psk) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:851b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:851b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 3 for iran 3 def kharej3_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [3]...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:851b::1/64 dev azumi3\n") f.write("ip -6 route add 2002:851b::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping3() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:851b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:851b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharej4_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik4(psk) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:861b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:861b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 4 for iran 4 def kharej4_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [4]...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:861b::1/64 dev azumi4\n") f.write("ip -6 route add 2002:861b::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping4() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:861b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:861b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharej5_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prik5(psk) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:871b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:871b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # kharej 5 for iran 5 def kharej5_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server \033[92m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server [5]...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:871b::1/64 dev azumi5\n") f.write("ip -6 route add 2002:871b::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping5() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:871b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:871b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran1_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:831b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() # edit def iran1_private_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii1(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi1\n") f.write("ip -6 route add 2002::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:831b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() ## route for iran1_private_menu def iran1_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[1]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[1]...\033[0m") if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii1(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add 2002:831b::2/64 dev azumi1\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi1\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::2\n".format( interface ) with open("/etc/private1.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron1_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping1_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:831b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() def iran2_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:841b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() # edit def iran2_private_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii2(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi2\n") f.write("ip -6 route add 2002::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:841b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() ## default route iran2_private_menu def iran2_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[2]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[2]...\033[0m") if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii2(psk) initial_ip = "2002:841b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:841b::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add 2002:841b::2/64 dev azumi2\n") f.write("ip -6 route add 2002:841b::1/64 dev azumi2\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:841b::2\n".format( interface ) with open("/etc/private2.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping2_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:841b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:841b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() def iran3_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:851b::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:851b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() # edit def iran3_private_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii3(psk) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi3\n") f.write("ip -6 route add 2002::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:851b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() ## default route iran3_private_menu def iran3_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[3]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[3]...\033[0m") if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii3(psk) initial_ip = "2002:851b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:851b::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add 2002:851b::2/64 dev azumi3\n") f.write("ip -6 route add 2002:851b::1/64 dev azumi3\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:851b::2\n".format( interface ) with open("/etc/private3.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping3_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:851b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:851b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() def iran4_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:861b::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:861b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() # edit def iran4_private_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii4(psk) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi4\n") f.write("ip -6 route add 2002::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:861b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() ##default route iran4_private_menu def iran4_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[4]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[4]...\033[0m") if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii4(psk) initial_ip = "2002:861b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:861b::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add 2002:861b::2/64 dev azumi4\n") f.write("ip -6 route add 2002:861b::1/64 dev azumi4\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:861b::2\n".format( interface ) with open("/etc/private4.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping4_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:861b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:861b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() def iran5_private_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:871b::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:871b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() # edit def iran5_private_edit(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii5(psk) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002::/16", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi5\n") f.write("ip -6 route add 2002::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:871b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() # default route iran5_private_menu def iran5_private2_ipsec(): print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Server\033[96m[5]\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mAdding private IP addresses for Server[5]...\033[0m") if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") print("\033[93m─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_prii5(psk) initial_ip = "2002:871b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "2002:871b::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) display_notification("\033[93mAdding commands...\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add 2002:871b::2/64 dev azumi5\n") f.write("ip -6 route add 2002:871b::1/64 dev azumi5\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:871b::2\n".format( interface ) with open("/etc/private5.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") runsec_ping5_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:871b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:871b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() ##### PRIVATE 5 kharej 1 iran # gen simple ipv4 & native multi def gen_multi_menuz(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP \033[0m") print("2. \033[93mGeneve + Native\033[0m") print("3. \033[96mGeneve + IPv4 + GRE6\033[0m") print("4. \033[92mGeneve + Native + GRE6\033[0m") print("5. \033[96mGeneve + IPsec\033[0m") print("6. \033[93mGeneve + IPsec + GRE6\033[0m") print("7. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_multi_ip() break elif server_type == "2": gen_multin_ip() break elif server_type == "3": gengre_ipv4_ip() break elif server_type == "4": gengre_native_ip() break elif server_type == "5": gen_ipsec_multi1() break elif server_type == "6": gen_ipsec_multi2() break elif server_type == "7": choose_reset2() break elif server_type == "0": clear() multiserver_mnu() break else: print("Invalid choice.") def gen_multi_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve IPV4 Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_gen() break elif server_type == "2": kharej1_gen() break elif server_type == "3": clear() gen_multi_menuz() break else: print("Invalid choice.") def kharej5_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]Kharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_s1() break elif server_type == "2": kharej5_s2() break elif server_type == "3": kharej5_s3() break elif server_type == "4": kharej5_s4() break elif server_type == "5": kharej5_s5() break elif server_type == "6": iran1_q_gen() break elif server_type == "0": clear() gen_multi_ip() break else: print("Invalid choice.") def iran1_q_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran52_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def kharej1_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]IRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran5_s1() break elif server_type == "2": iran5_s2() break elif server_type == "3": iran5_s3() break elif server_type == "4": iran5_s4() break elif server_type == "5": iran5_s5() break elif server_type == "6": kharej1_q_gen() break elif server_type == "0": clear() gen_multi_ip() break else: print("Invalid choice.") def kharej1_q_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "kharej52_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def gen1_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db3::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gen2_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db3::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) # 2 def gen3_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db4::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gen4_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db4::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) # 3 def gen5_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db5::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gen6_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db5::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) # 4 def gen7_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db6::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gen8_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db6::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) # 5 def gen9_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db7::2"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gen10_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run(["ping", "-c", "2", "2001:db7::1"], check=True) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_kh1_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping1_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping1_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping1_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping1_gen.service"]) def ping_kh2_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping2_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping2_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping2_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping2_gen.service"]) def ping_kh3_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping3_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping3_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping3_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping3_gen.service"]) def ping_kh4_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping4_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping4_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping4_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping4_gen.service"]) def ping_kh5_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping5_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping5_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping5_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping5_gen.service"]) def gen1_job(): file_path = "/etc/sys1.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gen2_job(): file_path = "/etc/sys2.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gen3_job(): file_path = "/etc/sys3.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gen4_job(): file_path = "/etc/sys4.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def gen5_job(): file_path = "/etc/sys5.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def kharej5_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 2 def kharej5_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 3 def kharej5_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 4 def kharej5_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 5 def kharej5_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV4 address: \033[0m" ) ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # native def gen_multin_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mNative\033[93m Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5n_gen() break elif server_type == "2": kharej1n_gen() break elif server_type == "3": clear() gen_multi_menuz() break else: print("Invalid choice.") def kharej5n_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]Kharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5n_s1() break elif server_type == "2": kharej5n_s2() break elif server_type == "3": kharej5n_s3() break elif server_type == "4": kharej5n_s4() break elif server_type == "5": kharej5n_s5() break elif server_type == "6": iran1_qn_gen() break elif server_type == "0": clear() gen_multin_ip() break else: print("Invalid choice.") def iran1_qn_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "iran52n_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def kharej1n_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]IRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran5n_s1() break elif server_type == "2": iran5n_s2() break elif server_type == "3": iran5n_s3() break elif server_type == "4": iran5n_s4() break elif server_type == "5": iran5n_s5() break elif server_type == "6": kharej1_qn_gen() break elif server_type == "0": clear() gen_multin_ip() break else: print("Invalid choice.") def kharej1_qn_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "kharej52n_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def kharej5n_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52n_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5n_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52n_s1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys1.sh"): os.remove("/etc/sys1.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db3::1") ufw("2001:db3::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 2 def kharej5n_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52n_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5n_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52n_s2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys2.sh"): os.remove("/etc/sys2.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db4::1") ufw("2001:db4::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 3 def kharej5n_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52n_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5n_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52n_s3(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys3.sh"): os.remove("/etc/sys3.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db5::1") ufw("2001:db5::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 4 def kharej5n_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52n_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5n_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52n_s4(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys4.sh"): os.remove("/etc/sys4.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db6::1") ufw("2001:db6::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # 5 def kharej5n_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def kharej52n_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran5n_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def iran52n_s5(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mServer 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys5.sh"): os.remove("/etc/sys5.sh") remote_ip = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m IPV6 address: \033[0m" ) ufw(remote_ip) ufw("2001:db7::1") ufw("2001:db7::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") # gen gre6 ipv4 # gen gre6 ipv4 multi def gengre_ipv4_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve \033[92mGRE6 \033[96mIPV4\033[93m Multi Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_genp4_gre() break elif server_type == "2": kharej11_genp4_gre() break elif server_type == "3": clear() gen_multi_menuz() break else: print("Invalid choice.") def kharej5_genp4_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_kharej_gre1() break elif server_type == "2": genp4_kharej_gre2() break elif server_type == "3": genp4_kharej_gre3() break elif server_type == "4": genp4_kharej_gre4() break elif server_type == "5": genp4_kharej_gre5() break elif server_type == "6": iranp4_question() break elif server_type == "0": clear() gengre_ipv4_ip() break else: print("Invalid choice.") def iranp4_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genp4_iran2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def kharej11_genp4_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_iran_gre1() break elif server_type == "2": genp4_iran_gre2() break elif server_type == "3": genp4_iran_gre3() break elif server_type == "4": genp4_iran_gre4() break elif server_type == "5": genp4_iran_gre5() break elif server_type == "6": kharejp4_question() break elif server_type == "0": clear() gengre_ipv4_ip() break else: print("Invalid choice.") def kharejp4_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genp4_kharej2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) # 1 def gre6k__multip4_tunnel1(): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gre local fd1d:fc98:b73e:b481::1 remote fd1d:fc98:b73e:b481::2\n" ) f.write("ip -6 addr add 2002:831a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:831a::2/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multip4_tunnel1(): gre6k__multip4_tunnel1() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def kharejp4_gre6_menu1(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi1\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") rungen_pingz1() # geninja sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") kharej_gre6multip4_tunnel1() sleep(1) def geneve_multip4_grek61(): ufw("2001:db3::1") ufw("2001:db3::2") ufw("2002:831a::1") ufw("2002:831a::2") ufw("fd1d:fc98:b73e:b481::1") ufw("fd1d:fc98:b73e:b481::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() # injaa print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_kharej_gre1(): global local_ip, remote_ip display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharejp4_gre6_menu1() geneve_multip4_grek61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_kharej2_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) kharejp4_gre6_menu1() geneve_multip4_grek61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multip4_tunnel1(): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gre local fd1d:fc98:b73e:b481::2 remote fd1d:fc98:b73e:b481::1\n" ) f.write("ip -6 addr add 2002:831a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:831a::1/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multip4_tunnel1(): gre6i__multip4_tunnel1() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def iranp4_gre6_menu1(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi1\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran1_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() iran_gre6multip4_tunnel1() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def genevep4_multip4_grei61(): ufw("2001:db3::1") ufw("2001:db3::2") ufw("2002:831a::1") ufw("2002:831a::2") ufw("fd1d:fc98:b73e:b481::1") ufw("fd1d:fc98:b73e:b481::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_iran_gre1(): global local_ip, remote_ip display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iranp4_gre6_menu1() genevep4_multip4_grei61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_iran2_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) iranp4_gre6_menu1() genevep4_multip4_grei61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 2 def gre6k__multip4_tunnel2(): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gre local fd1d:fc98:b73e:b581::1 remote fd1d:fc98:b73e:b581::2\n" ) f.write("ip -6 addr add 2002:841a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:841a::2/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multip4_tunnel2(): gre6k__multip4_tunnel2() ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def kharejp4_gre6_menu2(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b581::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b581::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b581::1/64 dev azumi2\n") f.write("ip -6 route add fd1d:fc98:b73e:b581::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") rungen_pingz2() # injagen2 sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b581::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") kharej_gre6multip4_tunnel2() def geneve_multip4_grek62(): ufw("2001:db4::1") ufw("2001:db4::2") ufw("2002:841a::1") ufw("2002:841a::2") ufw("fd1d:fc98:b73e:b581::1") ufw("fd1d:fc98:b73e:b581::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", "2002:841a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote 2002:841a::2\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_kharej_gre2(): global local_ip, remote_ip display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharejp4_gre6_menu2() geneve_multip4_grek62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_kharej2_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) kharejp4_gre6_menu2() geneve_multip4_grek62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multip4_tunnel2(): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gre local fd1d:fc98:b73e:b581::2 remote fd1d:fc98:b73e:b581::1\n" ) f.write("ip -6 addr add 2002:841a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:841a::1/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multip4_tunnel2(): gre6i__multip4_tunnel2() ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def iranp4_gre6_menu2(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b581::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b581::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b581::2/64 dev azumi2\n") f.write("ip -6 route add fd1d:fc98:b73e:b581::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran2_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b581::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() iran_gre6multip4_tunnel2() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def genevep4_multip4_grei62(): ufw("2001:db4::1") ufw("2001:db4::2") ufw("2002:841a::1") ufw("2002:841a::2") ufw("fd1d:fc98:b73e:b581::1") ufw("fd1d:fc98:b73e:b581::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", "2002:841a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote 2002:841a::1\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_iran_gre2(): global local_ip, remote_ip display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iranp4_gre6_menu2() genevep4_multip4_grei62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_iran2_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) iranp4_gre6_menu2() genevep4_multip4_grei62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 3 def gre6k__multip4_tunnel3(): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gre local fd1d:fc98:b73e:b681::1 remote fd1d:fc98:b73e:b681::2\n" ) f.write("ip -6 addr add 2002:851a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:851a::2/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multip4_tunnel3(): gre6k__multip4_tunnel3() ip_address = "2002:851a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def kharejp4_gre6_menu3(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b681::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b681::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b681::1/64 dev azumi3\n") f.write("ip -6 route add fd1d:fc98:b73e:b681::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") rungen_pingz3() # geninja3 sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b681::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") kharej_gre6multip4_tunnel3() def geneve_multip4_grek63(): ufw("2001:db5::1") ufw("2001:db5::2") ufw("2002:851a::1") ufw("2002:851a::2") ufw("fd1d:fc98:b73e:b681::1") ufw("fd1d:fc98:b73e:b681::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", "2002:851a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote 2002:851a::2\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_kharej_gre3(): global local_ip, remote_ip display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharejp4_gre6_menu3() geneve_multip4_grek63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_kharej2_gre3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) kharejp4_gre6_menu3() geneve_multip4_grek63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multip4_tunnel3(): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gre local fd1d:fc98:b73e:b681::2 remote fd1d:fc98:b73e:b681::1\n" ) f.write("ip -6 addr add 2002:851a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:851a::1/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multip4_tunnel3(): gre6i__multip4_tunnel3() ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def iranp4_gre6_menu3(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b681::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b681::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b681::2/64 dev azumi3\n") f.write("ip -6 route add fd1d:fc98:b73e:b681::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran3_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b681::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() iran_gre6multip4_tunnel3() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def genevep4_multip4_grei63(): ufw("2001:db5::1") ufw("2001:db5::2") ufw("2002:851a::1") ufw("2002:851a::2") ufw("fd1d:fc98:b73e:b681::1") ufw("fd1d:fc98:b73e:b681::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", "2002:851a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote 2002:851a::1\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_iran_gre3(): global local_ip, remote_ip display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iranp4_gre6_menu3() genevep4_multip4_grei63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_iran2_gre3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[3]\033[93m IPV4 address: \033[0m" ) iranp4_gre6_menu3() genevep4_multip4_grei63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 4 def gre6k__multip4_tunnel4(): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gre local fd1d:fc98:b73e:b781::1 remote fd1d:fc98:b73e:b781::2\n" ) f.write("ip -6 addr add 2002:861a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:861a::2/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multip4_tunnel4(): gre6k__multip4_tunnel4() ip_address = "2002:861a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def kharejp4_gre6_menu4(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b781::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b781::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b781::1/64 dev azumi4\n") f.write("ip -6 route add fd1d:fc98:b73e:b781::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") rungen_pingz4() # geninja4 sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b781::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") kharej_gre6multip4_tunnel4() def geneve_multip4_grek64(): ufw("2001:db6::1") ufw("2001:db6::2") ufw("2002:861a::1") ufw("2002:861a::2") ufw("fd1d:fc98:b73e:b781::1") ufw("fd1d:fc98:b73e:b781::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", "2002:861a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote 2002:861a::2\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_kharej_gre4(): global local_ip, remote_ip display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharejp4_gre6_menu4() geneve_multip4_grek64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_kharej2_gre4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) kharejp4_gre6_menu4() geneve_multip4_grek64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multip4_tunnel4(): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gre local fd1d:fc98:b73e:b781::2 remote fd1d:fc98:b73e:b781::1\n" ) f.write("ip -6 addr add 2002:861a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:861a::1/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multip4_tunnel4(): gre6i__multip4_tunnel4() ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def iranp4_gre6_menu4(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b781::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b781::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b781::2/64 dev azumi4\n") f.write("ip -6 route add fd1d:fc98:b73e:b781::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran4_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b781::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() iran_gre6multip4_tunnel4() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def genevep4_multip4_grei64(): ufw("2001:db6::1") ufw("2001:db6::2") ufw("2002:861a::1") ufw("2002:861a::2") ufw("fd1d:fc98:b73e:b781::1") ufw("fd1d:fc98:b73e:b781::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", "2002:861a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote 2002:861a::1\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_iran_gre4(): global local_ip, remote_ip display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iranp4_gre6_menu4() genevep4_multip4_grei64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_iran2_gre4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) iranp4_gre6_menu4() genevep4_multip4_grei64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 5 def gre6k__multip4_tunnel5(): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gre local fd1d:fc98:b73e:b881::1 remote fd1d:fc98:b73e:b881::2\n" ) f.write("ip -6 addr add 2002:871a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:871a::2/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multip4_tunnel5(): gre6k__multip4_tunnel5() ip_address = "2002:871a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def kharejp4_gre6_menu5(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b881::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b881::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b881::1/64 dev azumi5\n") f.write("ip -6 route add fd1d:fc98:b73e:b881::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") rungen_pingz5() # geninja5 sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b881::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") kharej_gre6multip4_tunnel5() def geneve_multip4_grek65(): ufw("2001:db7::1") ufw("2001:db7::2") ufw("2002:871a::1") ufw("2002:871a::2") ufw("fd1d:fc98:b73e:b881::1") ufw("fd1d:fc98:b73e:b881::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", "2002:871a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote 2002:871a::2\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_kharej_gre5(): global local_ip, remote_ip display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") kharejp4_gre6_menu5() geneve_multip4_grek65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_kharej2_gre5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) kharejp4_gre6_menu5() geneve_multip4_grek65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multip4_tunnel5(): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gre local fd1d:fc98:b73e:b881::2 remote fd1d:fc98:b73e:b881::1\n" ) f.write("ip -6 addr add 2002:871a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:871a::1/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multip4_tunnel5(): gre6i__multip4_tunnel5() ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def iranp4_gre6_menu5(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b881::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b881::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b881::2/64 dev azumi5\n") f.write("ip -6 route add fd1d:fc98:b73e:b881::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran5_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b881::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() iran_gre6multip4_tunnel5() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def genevep4_multip4_grei65(): ufw("2001:db7::1") ufw("2001:db7::2") ufw("2002:871a::1") ufw("2002:871a::2") ufw("fd1d:fc98:b73e:b881::1") ufw("fd1d:fc98:b73e:b881::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", "2002:871a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote 2002:871a::1\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def genp4_iran_gre5(): global local_ip, remote_ip display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") iranp4_gre6_menu5() genevep4_multip4_grei65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def genp4_iran2_gre5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) iranp4_gre6_menu5() genevep4_multip4_grei65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # gen native multi def gengre_native_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve \033[92mGRE6 \033[96mNative\033[93m Multi Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_gen_gre() break elif server_type == "2": kharej12_gen_gre() break elif server_type == "3": clear() gen_multi_menuz() break else: print("Invalid choice.") def kharej5_gen_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_kharej_gre1() break elif server_type == "2": gen_kharej_gre2() break elif server_type == "3": gen_kharej_gre3() break elif server_type == "4": gen_kharej_gre4() break elif server_type == "5": gen_kharej_gre5() break elif server_type == "6": iran_question() break elif server_type == "0": clear() gengre_native_ip() break else: print("Invalid choice.") def iran_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gen_iran2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def kharej12_gen_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_iran_gre1() break elif server_type == "2": gen_iran_gre2() break elif server_type == "3": gen_iran_gre3() break elif server_type == "4": gen_iran_gre4() break elif server_type == "5": gen_iran_gre5() break elif server_type == "6": kharej_question() break elif server_type == "0": clear() gengre_native_ip() break else: print("Invalid choice.") def kharej_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gen_kharej2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def gre6k__multi_tunnel1(): global local_ip, remote_ip file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:831a::2/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multi_tunnel1(): global local_ip, remote_ip gre6k__multi_tunnel1() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def geneve_multi_grek61(): ufw("2001:db3::1") ufw("2001:db3::2") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::1/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::2/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_kharej_gre1(): global local_ip, remote_ip display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6multi_tunnel1() geneve_multi_grek61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_kharej2_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) kharej_gre6multi_tunnel1() geneve_multi_grek61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multi_tunnel1(): global local_ip, remote_ip file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:831a::1/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multi_tunnel1(): global local_ip, remote_ip gre6i__multi_tunnel1() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def geneve_multi_grei61(): ufw("2001:db3::1") ufw("2001:db3::2") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen1", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen1", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db3::2/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db3::1/64", "dev", "azumigen1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys1.sh", "w") as f: f.write( f"sudo ip link add name azumigen1 type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen1 up\n") f.write("sudo ip addr add 2001:db3::2/64 dev azumigen1\n") f.write("sudo ip route add 2001:db3::1/64 dev azumigen1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" with open("/etc/sys1.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db3::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db3::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping1_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping1_sys.sh", 0o755) ping_kh1_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_iran_gre1(): global local_ip, remote_ip display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6multi_tunnel1() geneve_multi_grei61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_iran2_gre1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) iran_gre6multi_tunnel1() geneve_multi_grei61() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 2 def gre6k__multi_tunnel2(): global local_ip, remote_ip file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:841a::2/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multi_tunnel2(): global local_ip, remote_ip gre6k__multi_tunnel2() ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def geneve_multi_grek62(): ufw("2001:db4::1") ufw("2001:db4::2") ufw("2002:841a::1") ufw("2002:841a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", "2002:841a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote 2002:841a::2\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::1/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::2/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_kharej_gre2(): global local_ip, remote_ip display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6multi_tunnel2() geneve_multi_grek62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_kharej2_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) kharej_gre6multi_tunnel2() geneve_multi_grek62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multi_tunnel2(): global local_ip, remote_ip file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:841a::1/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multi_tunnel2(): global local_ip, remote_ip gre6i__multi_tunnel2() ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def geneve_multi_grei62(): ufw("2001:db4::1") ufw("2001:db4::2") ufw("2002:841a::1") ufw("2002:841a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen2", "type", "geneve", "id", "1000", "remote", "2002:841a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen2", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db4::2/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db4::1/64", "dev", "azumigen2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys2.sh", "w") as f: f.write( f"sudo ip link add name azumigen2 type geneve id 1000 remote 2002:841a::1\n" ) f.write("sudo ip link set azumigen2 up\n") f.write("sudo ip addr add 2001:db4::2/64 dev azumigen2\n") f.write("sudo ip route add 2001:db4::1/64 dev azumigen2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" with open("/etc/sys2.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db4::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db4::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping2_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping2_sys.sh", 0o755) ping_kh2_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_iran_gre2(): global local_ip, remote_ip display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6multi_tunnel2() geneve_multi_grei62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_iran2_gre2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) iran_gre6multi_tunnel2() geneve_multi_grei62() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 3 def gre6k__multi_tunnel3(): global local_ip, remote_ip file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:851a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:851a::2/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multi_tunnel3(): global local_ip, remote_ip gre6k__multi_tunnel3() ip_address = "2002:851a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def geneve_multi_grek63(): ufw("2001:db5::1") ufw("2001:db5::2") ufw("2002:851a::1") ufw("2002:851a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", "2002:851a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote 2002:851a::2\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::1/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::2/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen5_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_kharej_gre3(): global local_ip, remote_ip display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6multi_tunnel3() geneve_multi_grek63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_kharej2_gre3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) kharej_gre6multi_tunnel3() geneve_multi_grek63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multi_tunnel3(): global local_ip, remote_ip file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:851a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:851a::1/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multi_tunnel3(): global local_ip, remote_ip gre6i__multi_tunnel3() ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def geneve_multi_grei63(): ufw("2001:db5::1") ufw("2001:db5::2") ufw("2002:851a::1") ufw("2002:851a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen3", "type", "geneve", "id", "1000", "remote", "2002:851a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen3", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db5::2/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db5::1/64", "dev", "azumigen3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys3.sh", "w") as f: f.write( f"sudo ip link add name azumigen3 type geneve id 1000 remote 2002:851a::1\n" ) f.write("sudo ip link set azumigen3 up\n") f.write("sudo ip addr add 2001:db5::2/64 dev azumigen3\n") f.write("sudo ip route add 2001:db5::1/64 dev azumigen3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" with open("/etc/sys3.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen6_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db5::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db5::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping3_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping3_sys.sh", 0o755) ping_kh3_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_iran_gre3(): global local_ip, remote_ip display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6multi_tunnel3() geneve_multi_grei63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_iran2_gre3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) iran_gre6multi_tunnel3() geneve_multi_grei63() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 4 def gre6k__multi_tunnel4(): global local_ip, remote_ip file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:861a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:861a::2/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multi_tunnel4(): global local_ip, remote_ip gre6k__multi_tunnel4() ip_address = "2002:861a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def geneve_multi_grek64(): ufw("2001:db6::1") ufw("2001:db6::2") ufw("2002:861a::1") ufw("2002:861a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", "2002:861a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote 2002:861a::2\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::1/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::2/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen7_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_kharej_gre4(): global local_ip, remote_ip display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6multi_tunnel4() geneve_multi_grek64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_kharej2_gre4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) kharej_gre6multi_tunnel4() geneve_multi_grek64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multi_tunnel4(): global local_ip, remote_ip file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:861a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:861a::1/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multi_tunnel4(): global local_ip, remote_ip gre6i__multi_tunnel4() ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def geneve_multi_grei64(): ufw("2001:db6::1") ufw("2001:db6::2") ufw("2002:861a::1") ufw("2002:861a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen4", "type", "geneve", "id", "1000", "remote", "2002:861a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen4", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db6::2/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db6::1/64", "dev", "azumigen4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys4.sh", "w") as f: f.write( f"sudo ip link add name azumigen4 type geneve id 1000 remote 2002:861a::1\n" ) f.write("sudo ip link set azumigen4 up\n") f.write("sudo ip addr add 2001:db6::2/64 dev azumigen4\n") f.write("sudo ip route add 2001:db6::1/64 dev azumigen4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" with open("/etc/sys4.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen8_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db6::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db6::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping4_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping4_sys.sh", 0o755) ping_kh4_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_iran_gre4(): global local_ip, remote_ip display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6multi_tunnel4() geneve_multi_grei64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_iran2_gre4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) iran_gre6multi_tunnel4() geneve_multi_grei64() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 5 def gre6k__multi_tunnel5(): global local_ip, remote_ip file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:871a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:871a::2/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def kharej_gre6multi_tunnel5(): global local_ip, remote_ip gre6k__multi_tunnel5() ip_address = "2002:871a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def geneve_multi_grek65(): ufw("2001:db7::1") ufw("2001:db7::2") ufw("2002:871a::1") ufw("2002:871a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", "2002:871a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote 2002:871a::2\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::1/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::2/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen9_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mKharej Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_kharej_gre5(): global local_ip, remote_ip display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6multi_tunnel5() geneve_multi_grek65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_kharej2_gre5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) kharej_gre6multi_tunnel5() geneve_multi_grek65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # iran def gre6i__multi_tunnel5(): global local_ip, remote_ip file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gre local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:871a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:871a::1/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) sleep(1) subprocess.run(["bash", file_path], check=True) def iran_gre6multi_tunnel5(): global local_ip, remote_ip gre6i__multi_tunnel5() ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") iran_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def geneve_multi_grei65(): ufw("2001:db7::1") ufw("2001:db7::2") ufw("2002:871a::1") ufw("2002:871a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen5", "type", "geneve", "id", "1000", "remote", "2002:871a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen5", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db7::2/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "2001:db7::1/64", "dev", "azumigen5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys5.sh", "w") as f: f.write( f"sudo ip link add name azumigen5 type geneve id 1000 remote 2002:871a::1\n" ) f.write("sudo ip link set azumigen5 up\n") f.write("sudo ip addr add 2001:db7::2/64 dev azumigen5\n") f.write("sudo ip route add 2001:db7::1/64 dev azumigen5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" with open("/etc/sys5.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") gen10_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db7::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db7::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping5_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping5_sys.sh", 0o755) ping_kh5_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("\033[93mDon't forget to use \033[96mufw reload \033[0m") print("\033[93m───────────────────────────────────────\033[0m") def gen_iran_gre5(): global local_ip, remote_ip display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6multi_tunnel5() geneve_multi_grei65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_iran2_gre5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) iran_gre6multi_tunnel5() geneve_multi_grei65() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gen_ipsec_multi1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGeneve + IPsec \033[93mMulti Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGen IPsec IPV4 \033[0m") print("2. \033[93mGen IPsec Native\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen11_multi_ip4sec() break elif server_type == "2": gen11_ipsec_native() break elif server_type == "0": clear() gen_multi_menuz() break else: print("Invalid choice.") def gen11_multi_ip4sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mIPSec \033[93mIPV4 Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej51_ipsec_gen() break elif server_type == "2": kharej1_ipsec_gen() break elif server_type == "3": clear() gen_ipsec_multi1() break else: print("Invalid choice.") def kharej51_ipsec_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]Kharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() kharej5_s1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() kharej5_s2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() kharej5_s3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() kharej5_s4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() kharej5_s5() restart_forced_strongazumi() break elif server_type == "6": iran11_ipsec_gen() break elif server_type == "0": clear() gen11_multi_ip4sec() break else: print("Invalid choice.") def iran11_ipsec_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have? :\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "iran52_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def iran11_ipsec_genedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have? :\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) restart_forced_strongazumi() # edit2 def iran11_ipsec_genedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have s\033[96mright now? :\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecgeni(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def kharej1_ipsec_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92m[5]IRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() iran5_s1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() iran5_s2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() iran5_s3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() iran5_s4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() iran5_s5() restart_forced_strongazumi() break elif server_type == "6": kharej11_ipsec_gen() break elif server_type == "0": clear() gen11_multi_ip4sec() break else: print("Invalid choice.") def kharej11_ipsec_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have? :\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "kharej52_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def kharej11_ipsec_genedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have? :\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) restart_forced_strongazumi() # edit2 def kharej11_ipsec_genedit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now? :\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecgenk(psk, num_servers) restart_forced_strongazumi() # pre def config_ipsecgenk(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn Geneve{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2001:db{i+3}::1/64\n") f.write(f" leftid=2001:db{i+3}::1\n") f.write(f" right=2001:db{i+3}::2\n") f.write(f" rightsubnet=2001:db{i+3}::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2001:db{i+3}::2 2001:db{i+3}::1 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecgeni(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn Geneve{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2001:db{i+3}::2/64\n") f.write(f" leftid=2001:db{i+3}::2\n") f.write(f" right=2001:db{i+3}::1\n") f.write(f" rightsubnet=2001:db{i+3}::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2001:db{i+3}::1 2001:db{i+3}::2 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsec_genk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db3::1/64 leftid=2001:db3::1 right=2001:db3::2 rightsubnet=2001:db3::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db3::2 2001:db3::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # new def new1(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_genk1(psk) def new2(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_genk2(psk) def config_ipsec_genk2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db4::1/64 leftid=2001:db4::1 right=2001:db4::2 rightsubnet=2001:db4::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db4::2 2001:db4::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def new3(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_genk3(psk) def config_ipsec_genk3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db5::1/64 leftid=2001:db5::1 right=2001:db5::2 rightsubnet=2001:db5::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db5::2 2001:db5::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def new4(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_genk4(psk) def config_ipsec_genk4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db6::1/64 leftid=2001:db6::1 right=2001:db6::2 rightsubnet=2001:db6::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db6::2 2001:db6::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def new5(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_genk5(psk) def config_ipsec_genk5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db7::1/64 leftid=2001:db7::1 right=2001:db7::2 rightsubnet=2001:db7::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db7::2 2001:db7::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # iran config def newi1(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_geni1(psk) def config_ipsec_geni1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db3::2/64 leftid=2001:db3::2 right=2001:db3::1 rightsubnet=2001:db3::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db3::1 2001:db3::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def newi2(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_geni2(psk) def config_ipsec_geni2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db4::2/64 leftid=2001:db4::2 right=2001:db4::1 rightsubnet=2001:db4::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db4::1 2001:db4::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def newi3(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_geni3(psk) def config_ipsec_geni3(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db5::2/64 leftid=2001:db5::2 right=2001:db5::1 rightsubnet=2001:db5::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db5::1 2001:db5::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def newi4(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_geni4(psk) def config_ipsec_geni4(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db6::2/64 leftid=2001:db6::2 right=2001:db6::1 rightsubnet=2001:db6::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db6::1 2001:db6::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def newi5(): psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsec_geni5(psk) def config_ipsec_geni5(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn erspan5 left=%defaultroute leftsubnet=2001:db7::2/64 leftid=2001:db7::2 right=2001:db7::1 rightsubnet=2001:db7::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2001:db7::1 2001:db7::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # native def gen11_ipsec_native(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mIPsec Native\033[93m Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5n_ipsec_gen() break elif server_type == "2": kharej1n_ipsec_gen() break elif server_type == "3": clear() gen_ipsec_multi1() break else: print("Invalid choice.") def kharej5n_ipsec_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mIPsec [5]Kharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() kharej5n_s1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() kharej5n_s2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() kharej5n_s3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() kharej5n_s4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() kharej5n_s5() restart_forced_strongazumi() break elif server_type == "6": iran1_ipsecn_gen() break elif server_type == "0": clear() gen11_ipsec_native() break else: print("Invalid choice.") def iran1_ipsecn_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "iran52n_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def iran1_ipsecn_genedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) restart_forced_strongazumi() def kharej1n_ipsec_gen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mIPsec [5]IRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() iran5n_s1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() iran5n_s2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() iran5n_s3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() iran5n_s4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() iran5n_s5() restart_forced_strongazumi() break elif server_type == "6": kharej1_ipsecn_gen() break elif server_type == "0": clear() gen11_ipsec_native() break else: print("Invalid choice.") def kharej1_ipsecn_gen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "kharej52n_s{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def kharej1_ipsecn_genedit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) restart_forced_strongazumi() def gen_ipsec_multi2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGeneve GRE6 + IPsec \033[93mMulti Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGen IPsec IPV4 \033[0m") print("2. \033[93mGen IPsec Native\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengre_multi_ip4sec() break elif server_type == "2": gengre_multin_ip6sec() break elif server_type == "0": clear() gen_multi_menuz() break else: print("Invalid choice.") def gengre_multin_ip6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve \033[92mGRE6 \033[96mNative\033[93m Multi Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_ipsecgen_gre() break elif server_type == "2": kharej11_ipsecgen_gre() break elif server_type == "3": clear() gen_ipsec_multi2() break else: print("Invalid choice.") def kharej5_ipsecgen_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() gen_kharej_gre1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() gen_kharej_gre2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() gen_kharej_gre3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() gen_kharej_gre4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() gen_kharej_gre5() restart_forced_strongazumi() break elif server_type == "6": iran_ipsecz_question() break elif server_type == "0": clear() gengre_multin_ip6sec() break else: print("Invalid choice.") def iran_ipsecz_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gen_iran2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def iran_ipsecz_questione(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) restart_forced_strongazumi() # edit2 def iran_ipsecz_questione2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def kharej11_ipsecgen_gre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() gen_iran_gre1() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() gen_iran_gre2() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() gen_iran_gre3() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() gen_iran_gre4() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() gen_iran_gre5() break elif server_type == "6": kharej_ipsecz_question() break elif server_type == "0": clear() gengre_multin_ip6sec() break else: print("Invalid choice.") def kharej_ipsecz_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gen_kharej2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) # edit def kharej_ipsecz_questione(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) # edit2 def kharej_ipsecz_questione2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecgenk(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # ipsec gre6 ipv4 def gengre_multi_ip4sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve \033[92mGRE6 IPsec \033[96mIPV4\033[93m Multi Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN \033[0m") print("2. \033[93m[1]Kharej [5]IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_genp4_ipsecgre() break elif server_type == "2": kharej1_genp4_ipsecgre() break elif server_type == "3": clear() gen_ipsec_multi2() break else: print("Invalid choice.") def kharej5_genp4_ipsecgre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 IPsec \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[92mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[93mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() genp4_kharej_gre1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() genp4_kharej_gre2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() genp4_kharej_gre3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() genp4_kharej_gre4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() genp4_kharej_gre5() restart_forced_strongazumi() break elif server_type == "6": iranp4_ipsec_question() break elif server_type == "0": clear() gengre_multi_ip4sec() break else: print("Invalid choice.") def iranp4_ipsec_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "genp4_iran2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def iranp4_ipsec_questione(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgeni(psk, num_servers) restart_forced_strongazumi() # edit2 def iranp4_ipsec_questione2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecgeni(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def kharej1_genp4_ipsecgre(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[92mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[93mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() genp4_iran_gre1() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() genp4_iran_gre2() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() genp4_iran_gre3() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() genp4_iran_gre4() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() genp4_iran_gre5() restart_forced_strongazumi() break elif server_type == "6": kharejp4_ipsec_question() break elif server_type == "0": clear() gengre_multi_ip4sec() break else: print("Invalid choice.") def kharejp4_ipsec_question(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "genp4_kharej2_gre{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def kharejp4_ipsec_questione(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) restart_forced_strongazumi() # edit2 def kharejp4_ipsec_questione2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() enable_reset_ipsec() num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m: \033[0m") config_ipsecgenk(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() ## gre6tap simple def gre6tapmulti_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGRE6tap Multi\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPV4 Multi \033[0m") print("2. \033[93mGRE6tap Native Multi \033[0m") print("3. \033[92mGRE6tap IPV4 + \033[96mIPsec\033[92m Multi \033[0m") print("4. \033[93mGRE6tap Native + \033[96mIPsec\033[92m Multi \033[0m") print("5. \033[93mIPsec Reset Timer\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnu() gretap4m() break elif server_type == "2": gre6_reset_rmvmnu() gretapnm() break elif server_type == "3": gre6_reset_rmvmnu() gretap4m1() break elif server_type == "4": gre6_reset_rmvmnu() gretapnm1() break elif server_type == "5": choose_reset2() break elif server_type == "0": clear() multiserver_mnu() break else: print("Invalid choice.") # ip4 start def gretap4m(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mIPV4 \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN\033[0m") print("2. \033[93m[1] Kharej [5] IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap4mu_k() break elif server_type == "2": gre6tap4mu_i() break elif server_type == "3": clear() gre6tapmulti_mnu break else: print("Invalid choice.") def gre6tap4mu_k(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mIPV4 \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[92mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[96mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6_kharejz1() break elif server_type == "2": gre6tap6_kharejz2() break elif server_type == "3": gre6tap6_kharejz3() break elif server_type == "4": gre6tap6_kharejz4() break elif server_type == "5": gre6tap6_kharejz5() break elif server_type == "6": gre6tap6_kharejz6() break elif server_type == "7": gre6tap6_kharejz7() break elif server_type == "8": gre6tap6_kharejz8() break elif server_type == "9": gre6tap6_kharejz9() break elif server_type == "10": gre6tap6_kharejz10() break elif server_type == "11": irangretap4_q() break elif server_type == "0": clear() gretap4m() break else: print("Invalid choice.") def irangretap4_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6tap62_iranz{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def gre6tap4mu_i(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mIPV4 \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6_iranz1() break elif server_type == "2": gre6tap6_iranz2() break elif server_type == "3": gre6tap6_iranz3() break elif server_type == "4": gre6tap6_iranz4() break elif server_type == "5": gre6tap6_iranz5() break elif server_type == "6": kharejgretap4_q() break elif server_type == "0": clear() gretap4m() break else: print("Invalid choice.") def kharejgretap4_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6tap62_kharejz{}".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) def ping_v64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v64.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v64.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v64.service"]) subprocess.run(["systemctl", "start", "ping_v64.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v64.service"]) def ping_v65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v65.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v65.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v65.service"]) subprocess.run(["systemctl", "start", "ping_v65.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v65.service"]) def add_cron4_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private4.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private4.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def add_cron5_job(): try: subprocess.run( "crontab -l | grep -v '/etc/private5.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/private5.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_gre64_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip4.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip4.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip4.service"]) subprocess.run(["systemctl", "start", "ping_ip4.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip4.service"]) def iran_gre65_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip5.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip5.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip5.service"]) subprocess.run(["systemctl", "start", "ping_ip5.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip5.service"]) ## gre6tap ip4 server 1 def rungen_pingz1(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_pingz1(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b081::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel1(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:80{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:801a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnel1sec(remote_ip, local_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::1/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:801a::2/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:801a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz1(): remote_ip = "fd1d:fc98:b73e:b081::2" # iran-ip local_ip = "fd1d:fc98:b73e:b081::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel1(remote_ip, local_ip, num_additional_ips) ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def gre6tap_kharejz1sec(): remote_ip = "fd1d:fc98:b73e:b081::2" # iran-ip local_ip = "fd1d:fc98:b73e:b081::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnel1sec(remote_ip, local_ip) ip_address = "2002:801a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping1_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre61_service() gre61_cronjob() def kharej_gretap6_menu1(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b081::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b081::1/64 dev azumi1\n") f.write("ip -6 route add fd1d::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz1() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b081::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz1() sleep(1) def kharej_gretap6_menu1sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b081::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b081::2/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b081::1/64 dev azumi1\n") f.write("ip -6 route add fd1d:fc98:b73e:b081::2/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz1() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b081::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz1sec() sleep(1) def gretap6_iranz1(): remote_ip = "fd1d:fc98:b73e:b081::1" # kharej ip local_ip = "fd1d:fc98:b73e:b081::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz1(remote_ip, local_ip, num_additional_ips) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def gretap6_iranz1sec(): remote_ip = "fd1d:fc98:b73e:b081::1" # kharej ip local_ip = "fd1d:fc98:b73e:b081::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelz1sec(remote_ip, local_ip) ip_address = "2002:801a::1" # kharejip max_pings = 3 interval = 2 iran_ping1_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre61_service() gre61_cronjob() def gretap6_iran_tunnelz1(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002::/16 dev azumig61\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:80{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:801a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelz1sec(remote_ip, local_ip): file_path = "/etc/gre61.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig61 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:801a::2/64 dev azumig61\n") f.write("ip link set azumig61 up\n") f.write("ip -6 route add 2002:801a::1/64 dev azumig61\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:801a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran1_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b081::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu1(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b081::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b081::2/64 dev azumi1\n") f.write("ip -6 route add fd1d::/16 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran1_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b081::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() gretap6_iranz1() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def iran_gretap6_menu1sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private1.sh"): os.remove("/etc/private1.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi1", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi1", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b081::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi1"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b081::1/64", "dev", "azumi1"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private1.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi1 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi1 up\n") f.write("ip addr add fd1d:fc98:b73e:b081::2/64 dev azumi1\n") f.write("ip -6 route add fd1d:fc98:b73e:b081::1/64 dev azumi1\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" with open("/etc/private1.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private1.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron1_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran1_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b081::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v61.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v61.sh", 0o755) ping_v61_service() gretap6_iranz1sec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 2 def rungen_pingz2(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b581::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_pingz2(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b181::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel2(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002::/16 dev azumig62\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:81{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:811a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnel2sec(remote_ip, local_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::1/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:811a::2/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:811a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz2(): remote_ip = "fd1d:fc98:b73e:b181::2" # iran-ip local_ip = "fd1d:fc98:b73e:b181::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel2(remote_ip, local_ip, num_additional_ips) ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def gre6tap_kharejz2sec(): remote_ip = "fd1d:fc98:b73e:b181::2" # iran-ip local_ip = "fd1d:fc98:b73e:b181::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnel2sec(remote_ip, local_ip) ip_address = "2002:811a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping2_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre62_service() gre62_cronjob() def kharej_gretap6_menu2(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b181::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b181::1/64 dev azumi2\n") f.write("ip -6 route add fd1d::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz2() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b181::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz2() sleep(1) def kharej_gretap6_menu2sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b181::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b181::2/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b181::1/64 dev azumi2\n") f.write("ip -6 route add fd1d:fc98:b73e:b181::2/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz2() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b181::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz2sec() sleep(1) def gretap6_iranz2(): remote_ip = "fd1d:fc98:b73e:b181::1" # kharej ip local_ip = "fd1d:fc98:b73e:b181::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz2(remote_ip, local_ip, num_additional_ips) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def gretap6_iranz2sec(): remote_ip = "fd1d:fc98:b73e:b181::1" # kharej ip local_ip = "fd1d:fc98:b73e:b181::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelz2sec(remote_ip, local_ip) ip_address = "2002:811a::1" # kharejip max_pings = 3 interval = 2 iran_ping2_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre62_service() gre62_cronjob() def gretap6_iran_tunnelz2(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002::/16 dev azumig62\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:81{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelz2sec(remote_ip, local_ip): file_path = "/etc/gre62.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig62 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:811a::2/64 dev azumig62\n") f.write("ip link set azumig62 up\n") f.write("ip -6 route add 2002:811a::1/64 dev azumig62\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:811a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran2_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b181::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu2(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b181::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b181::2/64 dev azumi2\n") f.write("ip -6 route add fd1d::/16 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran2_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b181::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() gretap6_iranz2() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def iran_gretap6_menu2sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private2.sh"): os.remove("/etc/private2.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi2", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi2", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b181::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi2"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b181::1/64", "dev", "azumi2"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private2.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi2 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi2 up\n") f.write("ip addr add fd1d:fc98:b73e:b181::2/64 dev azumi2\n") f.write("ip -6 route add fd1d:fc98:b73e:b181::1/64 dev azumi2\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" with open("/etc/private2.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private2.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron2_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran2_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b181::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v62.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v62.sh", 0o755) ping_v62_service() gretap6_iranz2sec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 3 def rungen_pingz3(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b681::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_pingz3(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b281::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel3(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:821a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002::/16 dev azumig63\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:82{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnel3sec(remote_ip, local_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:821a::1/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:821a::2/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz3(): remote_ip = "fd1d:fc98:b73e:b281::2" # iran-ip local_ip = "fd1d:fc98:b73e:b281::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel3(remote_ip, local_ip, num_additional_ips) ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def gre6tap_kharejz3sec(): remote_ip = "fd1d:fc98:b73e:b281::2" # iran-ip local_ip = "fd1d:fc98:b73e:b281::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnel3sec(remote_ip, local_ip) ip_address = "2002:821a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping3_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre63_service() gre63_cronjob() def kharej_gretap6_menu3(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b281::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b281::1/64 dev azumi3\n") f.write("ip -6 route add fd1d::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz3() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b281::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz3() sleep(1) def kharej_gretap6_menu3sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b281::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b281::2/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b281::1/64 dev azumi3\n") f.write("ip -6 route add fd1d:fc98:b73e:b281::2/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz3() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b281::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz3sec() sleep(1) def gretap6_iranz3(): remote_ip = "fd1d:fc98:b73e:b281::1" # kharej ip local_ip = "fd1d:fc98:b73e:b281::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz3(remote_ip, local_ip, num_additional_ips) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def gretap6_iranz3sec(): remote_ip = "fd1d:fc98:b73e:b281::1" # kharej ip local_ip = "fd1d:fc98:b73e:b281::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelz3sec(remote_ip, local_ip) ip_address = "2002:821a::1" # kharejip max_pings = 3 interval = 2 iran_ping3_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre63_service() gre63_cronjob() def gretap6_iran_tunnelz3(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:821a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002::/16 dev azumig63\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:82{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelz3sec(remote_ip, local_ip): file_path = "/etc/gre63.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig63 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:821a::2/64 dev azumig63\n") f.write("ip link set azumig63 up\n") f.write("ip -6 route add 2002:821a::1/64 dev azumig63\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:821a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran3_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b281::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu3(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b281::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b281::2/64 dev azumi3\n") f.write("ip -6 route add fd1d::/16 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran3_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b281::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() gretap6_iranz3() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def iran_gretap6_menu3sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private3.sh"): os.remove("/etc/private3.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi3", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi3", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b281::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi3"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b281::1/64", "dev", "azumi3"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private3.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi3 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi3 up\n") f.write("ip addr add fd1d:fc98:b73e:b281::2/64 dev azumi3\n") f.write("ip -6 route add fd1d:fc98:b73e:b281::1/64 dev azumi3\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" with open("/etc/private3.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private3.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron3_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran3_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b281::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v63.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v63.sh", 0o755) ping_v63_service() gretap6_iranz3sec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz3(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 4 def rungen_pingz4(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b781::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_pingz4(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b381::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel4(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002::/16 dev azumig64\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnel4sec(remote_ip, local_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::1/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:831a::2/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz4(): remote_ip = "fd1d:fc98:b73e:b381::2" # iran-ip local_ip = "fd1d:fc98:b73e:b381::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel4(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def gre6tap_kharejz4sec(): remote_ip = "fd1d:fc98:b73e:b381::2" # iran-ip local_ip = "fd1d:fc98:b73e:b381::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnel4sec(remote_ip, local_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping4_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre64_service() gre64_cronjob() def kharej_gretap6_menu4(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b381::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b381::1/64 dev azumi4\n") f.write("ip -6 route add fd1d::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz4() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b381::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz4() sleep(1) def kharej_gretap6_menu4sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b381::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b381::2/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b381::1/64 dev azumi4\n") f.write("ip -6 route add fd1d:fc98:b73e:b381::2/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz4() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b381::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz4sec() sleep(1) def gretap6_iranz4(): remote_ip = "fd1d:fc98:b73e:b381::1" # kharej ip local_ip = "fd1d:fc98:b73e:b381::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz4(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def gretap6_iranz4sec(): remote_ip = "fd1d:fc98:b73e:b381::1" # kharej ip local_ip = "fd1d:fc98:b73e:b381::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelz4sec(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping4_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre64_service() gre64_cronjob() def gretap6_iran_tunnelz4(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002::/16 dev azumig64\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelz4sec(remote_ip, local_ip): file_path = "/etc/gre64.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig64 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:831a::2/64 dev azumig64\n") f.write("ip link set azumig64 up\n") f.write("ip -6 route add 2002:831a::1/64 dev azumig64\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran4_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b381::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu4(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b381::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b381::2/64 dev azumi4\n") f.write("ip -6 route add fd1d::/16 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran4_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b381::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() gretap6_iranz4() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def iran_gretap6_menu4sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private4.sh"): os.remove("/etc/private4.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi4", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi4", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b381::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi4"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b381::1/64", "dev", "azumi4"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private4.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi4 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi4 up\n") f.write("ip addr add fd1d:fc98:b73e:b381::2/64 dev azumi4\n") f.write("ip -6 route add fd1d:fc98:b73e:b381::1/64 dev azumi4\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" with open("/etc/private4.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private4.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron4_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran4_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b381::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v64.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v64.sh", 0o755) ping_v64_service() gretap6_iranz4sec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz4(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 5 def rungen_pingz5(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b881::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_pingz5(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel5(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002::/16 dev azumig65\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:84{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_tunnel5sec(remote_ip, local_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::1/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:841a::2/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz5(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel5(remote_ip, local_ip, num_additional_ips) ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def gre6tap_kharejz5sec(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6tap_tunnel5sec(remote_ip, local_ip) ip_address = "2002:841a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping5_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre65_service() gre65_cronjob() def kharej_gretap6_menu5(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi5\n") f.write("ip -6 route add fd1d::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz5() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz5() sleep(1) def kharej_gretap6_menu5sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi5\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz5() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz5sec() sleep(1) def gretap6_iranz5(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz5(remote_ip, local_ip, num_additional_ips) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def gretap6_iranz5sec(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gretap6_iran_tunnelz5sec(remote_ip, local_ip) ip_address = "2002:841a::1" # kharejip max_pings = 3 interval = 2 iran_ping5_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre65_service() gre65_cronjob() def gretap6_iran_tunnelz5(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002::/16 dev azumig65\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:84{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gretap6_iran_tunnelz5sec(remote_ip, local_ip): file_path = "/etc/gre65.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig65 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:841a::2/64 dev azumig65\n") f.write("ip link set azumig65 up\n") f.write("ip -6 route add 2002:841a::1/64 dev azumig65\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:841a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran5_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu5(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi5\n") f.write("ip -6 route add fd1d::/16 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran5_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() gretap6_iranz5() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def iran_gretap6_menu5sec(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private5.sh"): os.remove("/etc/private5.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi5", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi5", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi5"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi5"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private5.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi5 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi5 up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi5\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi5\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" with open("/etc/private5.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private5.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron5_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran5_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v65.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v65.sh", 0o755) ping_v65_service() gretap6_iranz5sec() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz5(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 6 def run_pingz6(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b581::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel6(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig66 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:851a::1/64 dev azumig66\n") f.write("ip link set azumig66 up\n") f.write("ip -6 route add 2002::/16 dev azumig66\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:85{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig66\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:851a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz6(): remote_ip = "fd1d:fc98:b73e:b581::2" # iran-ip local_ip = "fd1d:fc98:b73e:b581::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel6(remote_ip, local_ip, num_additional_ips) ip_address = "2002:851a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping6_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre66_service() gre66_cronjob() def kharej_gretap6_menu6(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b581::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add fd1d:fc98:b73e:b581::1/64 dev azumi6\n") f.write("ip -6 route add fd1d::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz6() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b581::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz6() sleep(1) def gretap6_iranz6(): remote_ip = "fd1d:fc98:b73e:b581::1" # kharej ip local_ip = "fd1d:fc98:b73e:b581::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz6(remote_ip, local_ip, num_additional_ips) ip_address = "2002:851a::1" # kharejip max_pings = 3 interval = 2 iran_ping6_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre66_service() gre66_cronjob() def gretap6_iran_tunnelz6(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre66.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig66 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:851a::2/64 dev azumig66\n") f.write("ip link set azumig66 up\n") f.write("ip -6 route add 2002::/16 dev azumig66\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:85{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig66\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:851a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran6_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b581::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu6(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private6.sh"): os.remove("/etc/private6.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi6", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi6", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b581::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi6"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private6.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi6 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi6 up\n") f.write("ip addr add fd1d:fc98:b73e:b581::2/64 dev azumi6\n") f.write("ip -6 route add fd1d::/16 dev azumi6\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" with open("/etc/private6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private6.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron6_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran6_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b581::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v66.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v66.sh", 0o755) ping_v66_service() gretap6_iranz6() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[6]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz6(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 6\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[6]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu6() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 7 def run_pingz7(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b681::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel7(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig67 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:861a::1/64 dev azumig67\n") f.write("ip link set azumig67 up\n") f.write("ip -6 route add 2002::/16 dev azumig67\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:86{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig67\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:861a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz7(): remote_ip = "fd1d:fc98:b73e:b681::2" # iran-ip local_ip = "fd1d:fc98:b73e:b681::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel7(remote_ip, local_ip, num_additional_ips) ip_address = "2002:861a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping7_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre67_service() gre67_cronjob() def kharej_gretap6_menu7(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b681::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add fd1d:fc98:b73e:b681::1/64 dev azumi7\n") f.write("ip -6 route add fd1d::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz7() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b681::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz7() sleep(1) def gretap6_iranz7(): remote_ip = "fd1d:fc98:b73e:b681::1" # kharej ip local_ip = "fd1d:fc98:b73e:b681::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz7(remote_ip, local_ip, num_additional_ips) ip_address = "2002:861a::1" # kharejip max_pings = 3 interval = 2 iran_ping7_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre67_service() gre67_cronjob() def gretap6_iran_tunnelz7(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre67.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig67 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:861a::2/64 dev azumig67\n") f.write("ip link set azumig67 up\n") f.write("ip -6 route add 2002::/16 dev azumig67\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:86{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig67\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:861a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran7_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b681::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu7(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private7.sh"): os.remove("/etc/private7.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi7", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi7", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b681::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi7"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private7.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi7 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi7 up\n") f.write("ip addr add fd1d:fc98:b73e:b681::2/64 dev azumi7\n") f.write("ip -6 route add fd1d::/16 dev azumi7\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" with open("/etc/private7.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private7.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron7_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran7_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b681::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v67.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v67.sh", 0o755) ping_v67_service() gretap6_iranz7() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[7]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz7(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 7\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[7]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu7() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 8 def run_pingz8(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b781::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel8(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig68 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:871a::1/64 dev azumig68\n") f.write("ip link set azumig68 up\n") f.write("ip -6 route add 2002::/16 dev azumig68\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:87{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig68\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:871a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz8(): remote_ip = "fd1d:fc98:b73e:b781::2" # iran-ip local_ip = "fd1d:fc98:b73e:b781::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel8(remote_ip, local_ip, num_additional_ips) ip_address = "2002:871a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping8_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre68_service() gre68_cronjob() def kharej_gretap6_menu8(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b781::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add fd1d:fc98:b73e:b781::1/64 dev azumi8\n") f.write("ip -6 route add fd1d::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz8() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b781::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz8() sleep(1) def gretap6_iranz8(): remote_ip = "fd1d:fc98:b73e:b781::1" # kharej ip local_ip = "fd1d:fc98:b73e:b781::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz8(remote_ip, local_ip, num_additional_ips) ip_address = "2002:871a::1" # kharejip max_pings = 3 interval = 2 iran_ping8_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre68_service() gre68_cronjob() def gretap6_iran_tunnelz8(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre68.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig68 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:871a::2/64 dev azumig68\n") f.write("ip link set azumig68 up\n") f.write("ip -6 route add 2002::/16 dev azumig68\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:87{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig68\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:871a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran8_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b781::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu8(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private8.sh"): os.remove("/etc/private8.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi8", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi8", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b781::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi8"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private8.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi8 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi8 up\n") f.write("ip addr add fd1d:fc98:b73e:b781::2/64 dev azumi8\n") f.write("ip -6 route add fd1d::/16 dev azumi8\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" with open("/etc/private8.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private8.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron8_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran8_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b781::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v68.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v68.sh", 0o755) ping_v68_service() gretap6_iranz8() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[8]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz8(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 8\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[8]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu8() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 9 def run_pingz9(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b881::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel9(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig69 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:881a::1/64 dev azumig69\n") f.write("ip link set azumig69 up\n") f.write("ip -6 route add 2002::/16 dev azumig69\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:88{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig69\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:881a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz9(): remote_ip = "fd1d:fc98:b73e:b881::2" # iran-ip local_ip = "fd1d:fc98:b73e:b881::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel9(remote_ip, local_ip, num_additional_ips) ip_address = "2002:881a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping9_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre69_service() gre69_cronjob() def kharej_gretap6_menu9(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b881::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add fd1d:fc98:b73e:b881::1/64 dev azumi9\n") f.write("ip -6 route add fd1d::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz9() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b881::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz9() sleep(1) def gretap6_iranz9(): remote_ip = "fd1d:fc98:b73e:b881::1" # kharej ip local_ip = "fd1d:fc98:b73e:b881::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz9(remote_ip, local_ip, num_additional_ips) ip_address = "2002:881a::1" # kharejip max_pings = 3 interval = 2 iran_ping9_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre69_service() gre69_cronjob() def gretap6_iran_tunnelz9(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre69.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig69 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:881a::2/64 dev azumig69\n") f.write("ip link set azumig69 up\n") f.write("ip -6 route add 2002::/16 dev azumig69\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:88{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig69\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:881a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran9_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b881::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu9(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private9.sh"): os.remove("/etc/private9.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi9", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi9", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b881::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi9"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private9.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi9 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi9 up\n") f.write("ip addr add fd1d:fc98:b73e:b881::2/64 dev azumi9\n") f.write("ip -6 route add fd1d::/16 dev azumi9\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" with open("/etc/private9.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private9.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron9_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran9_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b881::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v69.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v69.sh", 0o755) ping_v69_service() gretap6_iranz9() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[9]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz9(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 9\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[9]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu9() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") # 10 def run_pingz10(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b981::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gre6tap_tunnel10(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig610 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:891a::1/64 dev azumig610\n") f.write("ip link set azumig610 up\n") f.write("ip -6 route add 2002::/16 dev azumig610\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:89{i}a::1" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig610\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:891a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6tap_kharejz10(): remote_ip = "fd1d:fc98:b73e:b891::2" # iran-ip local_ip = "fd1d:fc98:b73e:b891::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gre6tap_tunnel10(remote_ip, local_ip, num_additional_ips) ip_address = "2002:891a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping10_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre610_service() gre610_cronjob() def kharej_gretap6_menu10(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b891::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add fd1d:fc98:b73e:b981::1/64 dev azumi10\n") f.write("ip -6 route add fd1d::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_pingz10() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b981::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") gre6tap_kharejz10() sleep(1) def gretap6_iranz10(): remote_ip = "fd1d:fc98:b73e:b891::1" # kharej ip local_ip = "fd1d:fc98:b73e:b891::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6tap\033[97m tunnel: " ) ) gretap6_iran_tunnelz10(remote_ip, local_ip, num_additional_ips) ip_address = "2002:891a::1" # kharejip max_pings = 3 interval = 2 iran_ping10_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre610_service() gre610_cronjob() def gretap6_iran_tunnelz10(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre610.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe ip6_gre\n") f.write( f"ip link add name azumig610 type ip6gretap local {local_ip} remote {remote_ip}\n" ) f.write("ip -6 addr add 2002:891a::2/64 dev azumig610\n") f.write("ip link set azumig610 up\n") f.write("ip -6 route add 2002::/16 dev azumig610\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:89{i}a::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumig610\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(["bash", file_path], check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6tap]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" with open(file_path, "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:891a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran10_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b891::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def iran_gretap6_menu10(): os.system("clear") global local_ip, remote_ip print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring GRE6tap \033[92mIran\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private10.sh"): os.remove("/etc/private10.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi10", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi10", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b891::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi10"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private10.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi10 mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi10 up\n") f.write("ip addr add fd1d:fc98:b73e:b891::2/64 dev azumi10\n") f.write("ip -6 route add fd1d::/16 dev azumi10\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" with open("/etc/private10.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private10.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron10_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran10_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b891::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v610.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v610.sh", 0o755) ping_v610_service() gretap6_iranz10() display_notification("\033[93mConfiguring...\033[0m") sleep(1) display_checkmark("\033[92mGRE6tap Configuration Completed!\033[0m") def gre6tap6_kharejz10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10 \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[10]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz10(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 10\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[10]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu10() print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") ## native ipsec def config_ipsecn1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap1 left=%defaultroute leftsubnet=2002:801a::1/64 leftid=2002:801a::1 right=2002:801a::2 rightsubnet=2002:801a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:801a::2 2002:801a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn12(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap2 left=%defaultroute leftsubnet=2002:811a::1/64 leftid=2002:811a::1 right=2002:811a::2 rightsubnet=2002:811a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::2 2002:811a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn13(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap3 left=%defaultroute leftsubnet=2002:821a::1/64 leftid=2002:821a::1 right=2002:821a::2 rightsubnet=2002:821a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:821a::2 2002:821a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn14(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "a") as f: f.write( f"""config setup ##azumiisinyouarea conn gretap4 left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn15(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap5 left=%defaultroute leftsubnet=2002:841a::1/64 leftid=2002:841a::1 right=2002:841a::2 rightsubnet=2002:841a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:841a::2 2002:841a::1 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec1.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap1 left=%defaultroute leftsubnet=2002:801a::2/64 leftid=2002:801a::2 right=2002:801a::1 rightsubnet=2002:801a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:801a::1 2002:801a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn22(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec2.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec2.conf", "a") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap2 left=%defaultroute leftsubnet=2002:811a::2/64 leftid=2002:811a::2 right=2002:811a::1 rightsubnet=2002:811a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "a") as f: f.write(f'2002:811a::1 2002:811a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec2.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn23(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec3.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec3.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap3 left=%defaultroute leftsubnet=2002:821a::2/64 leftid=2002:821a::2 right=2002:821a::1 rightsubnet=2002:821a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:821a::1 2002:821a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec3.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn24(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec4.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec4.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap4 left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec4.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn25(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec5.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec5.conf", "w") as f: f.write( f"""config setup ##azumiisinyourarea conn gretap5 left=%defaultroute leftsubnet=2002:841a::2/64 leftid=2002:841a::2 right=2002:841a::1 rightsubnet=2002:841a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no\n""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:841a::1 2002:841a::2 : PSK "{psk}"\n') with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec5.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissions1() subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # start def gretapnm1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative + IPsec \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN\033[0m") print("2. \033[93m[1] Kharej [5] IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapmu_k1() break elif server_type == "2": gre6tapmu_i1() break elif server_type == "3": clear() gre6tapmulti_mnu break else: print("Invalid choice.") def gre6tapmu_k1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative +IPsec \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap_k11() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap_k21() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap_k31() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap_k41() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap_k51() restart_forced_strongazumi() break elif server_type == "6": enable_reset_ipsec() irangretap_q1() break elif server_type == "0": clear() gretapnm1() break else: print("Invalid choice.") def config_ipsecn1k(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::1/64\n") f.write(f" leftid=2002:8{i+0}1a::1\n") f.write(f" right=2002:8{i+0}1a::2\n") f.write(f" rightsubnet=2002:8{i+0}1a::2/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::2 2002:8{i+0}1a::1 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_ipsecn1i(psk, num_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "systemctl", "disable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "disable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "stop", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open(f"/etc/ipsec1.conf", "w") as f: f.write("config setup\n") f.write(' charondebug="all"\n') f.write(" uniqueids=no\n") f.write("##azumiisinyourarea\n") for i in range(num_servers): f.write(f"\nconn GRE6{i+1}\n") f.write(" left=%defaultroute\n") f.write(f" leftsubnet=2002:8{i+0}1a::2/64\n") f.write(f" leftid=2002:8{i+0}1a::2\n") f.write(f" right=2002:8{i+0}1a::1\n") f.write(f" rightsubnet=2002:8{i+0}1a::1/64\n") f.write(" ike=aes256gcm16-sha512-ecp384!\n") f.write(" esp=aes256gcm16-sha512-ecp384!\n") f.write(" keyexchange=ikev2\n") f.write(" auto=start\n") f.write(" authby=secret\n") f.write(" keyingtries=%forever\n") f.write(" dpdaction=restart\n") f.write(" dpddelay=30s\n") f.write(" dpdtimeout=120s\n") f.write(" rekeymargin=3m\n") f.write(" rekeyfuzz=100%\n") f.write(" reauth=no\n") subprocess.run( ["sudo", "chmod", "+x", f"/etc/ipsec1.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.secrets", "w") as f: for i in range(num_servers): f.write(f'2002:8{i+0}1a::1 2002:8{i+0}1a::2 : PSK "{psk}"\n') subprocess.run( ["sudo", "chmod", "+x", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write( """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork""" ) for i in range(num_servers): f.write(f" --conf /etc/ipsec1.conf") f.write( """ ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target\n""" ) permissionz(num_servers) subprocess.run( ["sudo", "systemctl", "daemon-reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def irangretap_q1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gre6tap2_i{}1".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def irangretap_q1edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, num_servers) restart_forced_strongazumi() # edit2 def irangretap_q1edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecn1i(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def gre6tapmu_i1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mNative +IPsec \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap_i11() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap_i21() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap_i31() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap_i41() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap_i51() restart_forced_strongazumi() break elif server_type == "6": enable_reset_ipsec() kharejgretap_q1() break elif server_type == "0": clear() gretapnm1() break else: print("Invalid choice.") def kharejgretap_q1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gre6tap2_k{}1".format(i) globals()[menu_name]() restart_forced_strongazumi() # edit def kharejgretap_q1edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) restart_forced_strongazumi() # edit2 def kharejgretap_q1edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def gre6tap_k11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1(psk) ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tap_i11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn2(psk) ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel1() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # 2native def gre6tap_k21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn12(psk) ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tap_i21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn22(psk) ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel2() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 3native def gre6tap_k31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn13(psk) ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tap_i31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn23(psk) ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[3]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel3() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 4native def gre6tap_k41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn14(psk) ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tap_i41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn24(psk) ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel4() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") ##end # 5native def gre6tap_k51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") kharej_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn15(psk) ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_k51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) kharej_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # iran native def gre6tap_i51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV6 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV6 address: \033[0m") iran_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn25(psk) ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap2_i51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV6 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV6 address: \033[0m" ) iran_gre6tap_tunnel5() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") ##end ##IPsec IPv4 # ip4 start def gretap4m1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGre6tap + IPsec V4 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN\033[0m") print("2. \033[93m[1] Kharej [5] IRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap4mu_k1() break elif server_type == "2": gre6tap4mu_i1() break elif server_type == "3": clear() gre6tapmulti_mnu() break else: print("Invalid choice.") def gre6tap4mu_k1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mIPV4 + IPsec \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mIRAN\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap6_kharejz11() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap6_kharejz21() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap6_kharejz31() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap6_kharejz41() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap6_kharejz51() restart_forced_strongazumi() break elif server_type == "6": enable_reset_ipsec() irangretap4_q1() break elif server_type == "0": clear() gretap4m1() break else: print("Invalid choice.") def irangretap4_q1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gre6tap62_iranz{}1".format(i) if menu_name in globals(): globals()[menu_name]() else: print("Function {} does not exist.".format(menu_name)) restart_forced_strongazumi() # edit def irangretap4_q1edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1i(psk, num_servers) restart_forced_strongazumi() # edit2 def irangretap4_q1edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time!\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input( "\033[93mHow many \033[92mKharej Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m?: \033[0m") config_ipsecn1i(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) restart_forced_strongazumi() def gre6tap4mu_i1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mIPV4 \033[93m+\033[92m Gretap6 \033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[96mKharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap6_iranz11() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap6_iranz21() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap6_iranz31() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap6_iranz41() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap6_iranz51() break elif server_type == "6": enable_reset_ipsec() kharejgretap4_q1() break elif server_type == "0": clear() gretap4m1() break else: print("Invalid choice.") def kharejgretap4_q1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_config() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) for i in range(1, num_servers + 1): menu_name = "gre6tap62_kharejz{}1".format(i) globals()[menu_name]() # edit def kharejgretap4_q1edit(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset_ipsec() remove_config() num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) # edit2 def kharejgretap4_q1edit2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") enable_reset_ipsec() remove_config() num_servers = int( input( "\033[93mHow many \033[92mIRAN Servers\033[93m do you have \033[96mright now?\033[0m " ) ) psk = input("\033[93mWhat was your \033[92mSecret key\033[93m: \033[0m") config_ipsecn1k(psk, num_servers) subprocess.run( ["sudo", "systemctl", "restart", "strong-azumi1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def remove_config(): subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def gre6tap6_kharejz11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu1sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn1(psk) ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu1sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[1]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu1sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn2(psk) ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz11(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 1\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[1]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu1sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:801a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # 2 def gre6tap6_kharejz21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu2sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn12(psk) ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu2sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[2]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu2sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn22(psk) ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz21(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 2\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[2]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu2sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:811a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # 3 def gre6tap6_kharejz31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu3sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn13(psk) ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu3sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[3]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu3sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn23(psk) ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz31(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 3\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[3]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu3sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:821a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # 4 def gre6tap6_kharejz41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu4sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn14(psk) ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu4sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[4]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu4sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn24(psk) ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz41(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 4\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[4]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu4sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:831a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # 5 def gre6tap6_kharejz51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mkharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu5sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn15(psk) ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_kharejz51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej_gretap6_menu5sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::2" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap6_iranz51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[96m[5]\033[93m IPV4 address: \033[0m" ) remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu5sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_ipsecn25(psk) ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") def gre6tap62_iranz51(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[92mSERVER 5\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input( "\033[93mEnter \033[92mKharej\033[96m[5]\033[93m IPV4 address: \033[0m" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran_gretap6_menu5sec() print("\033[93m─────────────────────────────────────────────────────────\033[0m") ip_address = "2002:841a::1" # iranip print("\033[92m(\033[96mPlease wait,Azumi is pinging again...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) display_checkmark("\033[92mConfiguration is done!\033[0m") # edit server def edit_server(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mAdd | Edit | Reconfig Server \033[0m") print( "2. \033[93mRemove [for reconfiging, first remove the appropriate server] \033[0m" ) print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editmenu() break elif server_type == "2": removemenu() break elif server_type == "0": clear() multiserver_mnu() break else: print("Invalid choice.") def editmenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6 \033[0m") print("2. \033[92mIP6IP6 + IPSec \033[0m") print("3. \033[93mGRE6 \033[0m") print("4. \033[93mGRE6 + IPSec \033[0m") print("5. \033[96m6to4 \033[0m") print("6. \033[96m6to4 + IPSec \033[0m") print("7. \033[92mGRE6tap \033[0m") print("8. \033[92mGRE6tap + IPsec \033[0m") print("9. \033[93mGeneve [IPsec included] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_ip6ip6() break elif server_type == "2": edit_ip6ip6_sec() break elif server_type == "3": edit_gre6() break elif server_type == "4": edit_gre6_sec() break elif server_type == "5": edit_6to4() break elif server_type == "6": edit_6to4_sec() break elif server_type == "7": edit_gre6tap() break elif server_type == "8": edit_gre6tapsec() break elif server_type == "9": edit_geneve() break elif server_type == "0": clear() edit_server() break else: print("Invalid choice.") def edit_ip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [10] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_ip6ip6() break elif server_type == "2": oneiran_ip6ip6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_ip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[6] Kharej \033[0m") print("7. \033[93m[7] Kharej \033[0m") print("8. \033[93m[8] Kharej \033[0m") print("9. \033[92m[9] Kharej \033[0m") print("10.\033[93m[10] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_ipip61_menu() break elif server_type == "2": kharej_ipip62_menu() break elif server_type == "3": kharej_ipip63_menu() break elif server_type == "4": kharej_ipip64_menu() break elif server_type == "5": kharej_ipip65_menu() break elif server_type == "6": kharej_ipip66_menu() break elif server_type == "7": kharej_ipip67_menu() break elif server_type == "8": kharej_ipip68_menu() break elif server_type == "9": kharej_ipip69_menu() break elif server_type == "10": kharej_ipip610_menu() break elif server_type == "11": oneiran_one() break elif server_type == "0": clear() edit_ip6ip6() break else: print("Invalid choice.") def oneiran_one(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m IP6IP6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9] \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran_ipip61_menu() break elif server_type == "2": iran_ipip62_menu() break elif server_type == "3": iran_ipip63_menu() break elif server_type == "4": iran_ipip64_menu() break elif server_type == "5": iran_ipip65_menu() break elif server_type == "6": iran_ipip66_menu() break elif server_type == "7": iran_ipip67_menu() break elif server_type == "8": iran_ipip68_menu() break elif server_type == "9": iran_ipip69_menu() break elif server_type == "10": iran_ipip610_menu() break elif server_type == "0": clear() fivekharej_ip6ip6() break else: print("Invalid choice.") # ip6ip6 iran side def oneiran_ip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("6. \033[93m[6] IRAN \033[0m") print("7. \033[93m[7] IRAN \033[0m") print("8. \033[93m[8] IRAN \033[0m") print("9. \033[92m[9] IRAN \033[0m") print("10.\033[93m[10] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran2_ipip61_menu() break elif server_type == "2": iran2_ipip62_menu() break elif server_type == "3": iran2_ipip63_menu() break elif server_type == "4": iran2_ipip64_menu() break elif server_type == "5": iran2_ipip65_menu() break elif server_type == "6": iran2_ipip66_menu() break elif server_type == "7": iran2_ipip67_menu() break elif server_type == "8": iran2_ipip68_menu() break elif server_type == "9": iran2_ipip69_menu() break elif server_type == "10": iran2_ipip610_menu() break elif server_type == "11": onekharej_one() break elif server_type == "0": clear() edit_ip6ip6() break else: print("Invalid choice.") def onekharej_one(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m IP6IP6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9] \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej2_ipip61_menu() break elif server_type == "2": kharej2_ipip62_menu() break elif server_type == "3": kharej2_ipip63_menu() break elif server_type == "4": kharej2_ipip64_menu() break elif server_type == "5": kharej2_ipip65_menu() break elif server_type == "6": kharej2_ipip66_menu() break elif server_type == "7": kharej2_ipip67_menu() break elif server_type == "8": kharej2_ipip68_menu() break elif server_type == "9": kharej2_ipip69_menu() break elif server_type == "10": kharej2_ipip610_menu() break elif server_type == "0": clear() oneiran_ip6ip6() break else: print("Invalid choice.") # ip6ip6 ipsec def edit_ip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_ip6ip6_sec() break elif server_type == "2": oneiran_ip6ip6_sec() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side + ipsec def fivekharej_ip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharej_ipip61sec_menu() break elif server_type == "2": remove_config() enable_reset_ipsec() kharej_ipip62sec_menu() break elif server_type == "3": remove_config() enable_reset_ipsec() kharej_ipip63sec_menu() break elif server_type == "4": remove_config() enable_reset_ipsec() kharej_ipip64sec_menu() break elif server_type == "5": remove_config() enable_reset_ipsec() kharej_ipip65sec_menu() break elif server_type == "6": oneiran_one_ipipsec() break elif server_type == "0": clear() edit_ip6ip6_sec() break else: print("Invalid choice.") def oneiran_one_ipipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m IP6IP6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejip_qsecedit() iran_ipip61sec_menu() break elif server_type == "2": remove_config() enable_reset_ipsec() kharejip_qsecedit() iran_ipip62sec_menu() break elif server_type == "3": remove_config() enable_reset_ipsec() kharejip_qsecedit() iran_ipip63sec_menu() break elif server_type == "4": remove_config() enable_reset_ipsec() kharejip_qsecedit() iran_ipip64sec_menu() break elif server_type == "5": remove_config() enable_reset_ipsec() kharejip_qsecedit() iran_ipip65sec_menu() break elif server_type == "0": clear() fivekharej_ip6ip6_sec() break else: print("Invalid choice.") # ip6ip6 + IPsec iran side def oneiran_ip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit IP6IP6 + IPsaec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() iran2_ipip61sec_menu() break elif server_type == "2": remove_config() enable_reset_ipsec() iran2_ipip62sec_menu() break elif server_type == "3": remove_config() enable_reset_ipsec() iran2_ipip63sec_menu() break elif server_type == "4": remove_config() enable_reset_ipsec() iran2_ipip64sec_menu() break elif server_type == "5": remove_config() enable_reset_ipsec() iran2_ipip65sec_menu() break elif server_type == "6": onekharej_one_ipipsec() break elif server_type == "0": clear() edit_ip6ip6_sec() break else: print("Invalid choice.") def onekharej_one_ipipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m IP6IP6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() iranip_qsecedit() kharej2_ipip61sec_menu() break elif server_type == "2": remove_config() enable_reset_ipsec() iranip_qsecedit() kharej2_ipip62sec_menu() break elif server_type == "3": remove_config() enable_reset_ipsec() iranip_qsecedit() kharej2_ipip63sec_menu() break elif server_type == "4": remove_config() enable_reset_ipsec() iranip_qsecedit() kharej2_ipip64sec_menu() break elif server_type == "5": remove_config() enable_reset_ipsec() iranip_qsecedit() kharej2_ipip65sec_menu() break elif server_type == "0": clear() oneiran_ip6ip6_sec() break else: print("Invalid choice.") # GRE6 def edit_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6() break elif server_type == "2": oneiran_gre6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[6] Kharej \033[0m") print("7. \033[93m[7] Kharej \033[0m") print("8. \033[93m[8] Kharej \033[0m") print("9. \033[92m[9] Kharej \033[0m") print("10.\033[93m[10] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_gre61_menu() break elif server_type == "2": kharej_gre62_menu() break elif server_type == "3": kharej_gre63_menu() break elif server_type == "4": kharej_gre64_menu() break elif server_type == "5": kharej_gre65_menu() break elif server_type == "6": kharej_gre66_menu() break elif server_type == "7": kharej_gre67_menu() break elif server_type == "8": kharej_gre68_menu() break elif server_type == "9": kharej_gre69_menu() break elif server_type == "10": kharej_gre610_menu() break elif server_type == "11": oneiran_onegre6() break elif server_type == "0": clear() edit_gre6() break else: print("Invalid choice.") def oneiran_onegre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m GRE6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9] \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran_gre61_menu() break elif server_type == "2": iran_gre62_menu() break elif server_type == "3": iran_gre63_menu() break elif server_type == "4": iran_gre64_menu() break elif server_type == "5": iran_gre65_menu() break elif server_type == "6": iran_gre66_menu() break elif server_type == "7": iran_gre67_menu() break elif server_type == "8": iran_gre68_menu() break elif server_type == "9": iran_gre69_menu() break elif server_type == "10": iran_gre610_menu() break elif server_type == "0": clear() fivekharej_gre6() break else: print("Invalid choice.") # GRE6 iran side def oneiran_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran2_gre61_menu() break elif server_type == "2": iran2_gre62_menu() break elif server_type == "3": iran2_gre63_menu() break elif server_type == "4": iran2_gre64_menu() break elif server_type == "5": iran2_gre65_menu() break elif server_type == "6": onekharej_onegre6() break elif server_type == "0": clear() edit_gre6() break else: print("Invalid choice.") def onekharej_onegre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m GRE6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej2_gre61_menu() break elif server_type == "2": kharej2_gre62_menu() break elif server_type == "3": kharej2_gre63_menu() break elif server_type == "4": kharej2_gre64_menu() break elif server_type == "5": kharej2_gre65_menu() break elif server_type == "0": clear() oneiran_gre6() break else: print("Invalid choice.") # gre6 + ipsec def edit_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6_sec() break elif server_type == "2": oneiran_gre6_sec() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharej_gre61_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() kharej_gre62_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() kharej_gre63_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() kharej_gre64_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() kharej_gre65_ipsec() break elif server_type == "6": oneiran_onegre6_sec() break elif server_type == "0": clear() edit_gre6_sec() break else: print("Invalid choice.") def oneiran_onegre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m GRE6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejgre_qipsec_edit() iran_gre61_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() kharejgre_qipsec_edit() iran_gre62_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() kharejgre_qipsec_edit() iran_gre63_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() kharejgre_qipsec_edit() iran_gre64_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() kharejgre_qipsec_edit() iran_gre65_ipsec() break elif server_type == "0": clear() fivekharej_gre6_sec() break else: print("Invalid choice.") # GRE6 iran side def oneiran_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() iran2_gre61_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() iran2_gre62_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() iran2_gre63_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() iran2_gre64_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() iran2_gre65_ipsec() break elif server_type == "6": onekharej_onegre6_sec() break elif server_type == "0": clear() edit_gre6_sec() break else: print("Invalid choice.") def onekharej_onegre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m GRE6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() irangre_qipsec_edit() kharej2_gre61_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() irangre_qipsec_edit() kharej2_gre62_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() irangre_qipsec_edit() kharej2_gre63_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() irangre_qipsec_edit() kharej2_gre64_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() irangre_qipsec_edit() kharej2_gre65_ipsec() break elif server_type == "0": clear() oneiran_gre6_sec() break else: print("Invalid choice.") # 6to4 def edit_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_6to4() break elif server_type == "2": oneiran_6to4() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[6] Kharej \033[0m") print("7. \033[93m[7] Kharej \033[0m") print("8. \033[93m[8] Kharej \033[0m") print("9. \033[92m[9] Kharej \033[0m") print("10.\033[93m[10] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_private_menu() break elif server_type == "2": kharej2_private_menu() break elif server_type == "3": kharej3_private_menu() break elif server_type == "4": kharej4_private_menu() break elif server_type == "5": kharej5_private_menu() break elif server_type == "6": kharej6_private_menu() break elif server_type == "7": kharej7_private_menu() break elif server_type == "8": kharej8_private_menu() break elif server_type == "9": kharej9_private_menu() break elif server_type == "10": kharej10_private_menu() break elif server_type == "11": oneiran_one6to4() break elif server_type == "0": clear() edit_6to4() break else: print("Invalid choice.") def oneiran_one6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m 6TO4 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9 \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1_private_menu() break elif server_type == "2": iran2_private_menu() break elif server_type == "3": iran3_private_menu() break elif server_type == "4": iran4_private_menu() break elif server_type == "5": iran5_private_menu() break elif server_type == "6": iran6_private_menu() break elif server_type == "7": iran7_private_menu() break elif server_type == "8": iran8_private_menu() break elif server_type == "9": iran9_private_menu() break elif server_type == "10": iran10_private_menu() break elif server_type == "0": clear() fivekharej_6to4() break else: print("Invalid choice.") # 6TO4 iran side def oneiran_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1_private2_menu() break elif server_type == "2": iran2_private2_menu() break elif server_type == "3": iran3_private2_menu() break elif server_type == "4": iran4_private2_menu() break elif server_type == "5": iran5_private2_menu() break elif server_type == "6": onekharej_one6to4() break elif server_type == "0": clear() edit_6to4() break else: print("Invalid choice.") def onekharej_one6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m 6TO4 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_private2_menu() break elif server_type == "2": kharej2_private2_menu() break elif server_type == "3": kharej3_private2_menu() break elif server_type == "4": kharej4_private2_menu() break elif server_type == "5": kharej5_private2_menu() break elif server_type == "0": clear() oneiran_6to4() break else: print("Invalid choice.") # 6to4 + IPsec def edit_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_6to4_sec() break elif server_type == "2": oneiran_6to4_sec() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharej1_private_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() kharej2_private_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() kharej3_private_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() kharej4_private_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() kharej5_private_ipsec() break elif server_type == "6": oneiran_one6to4_sec() break elif server_type == "0": clear() edit_6to4_sec() break else: print("Invalid choice.") def oneiran_one6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m 6TO4 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharej_qpri_ipsecedit() iran1_private_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() kharej_qpri_ipsecedit() iran2_private_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() kharej_qpri_ipsecedit() iran3_private_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() kharej_qpri_ipsecedit() iran4_private_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() kharej_qpri_ipsecedit() iran5_private_ipsec() break elif server_type == "0": clear() fivekharej_6to4_sec() break else: print("Invalid choice.") # 6TO4 iran side def oneiran_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit 6TO4 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() iran1_private2_ipsec() restart_forced_strongazumi() break elif server_type == "2": remove_config() enable_reset_ipsec() iran2_private2_ipsec() restart_forced_strongazumi() break elif server_type == "3": remove_config() enable_reset_ipsec() iran3_private2_ipsec() restart_forced_strongazumi() break elif server_type == "4": remove_config() enable_reset_ipsec() iran4_private2_ipsec() restart_forced_strongazumi() break elif server_type == "5": remove_config() enable_reset_ipsec() iran5_private2_ipsec() restart_forced_strongazumi() break elif server_type == "6": onekharej_one6to4_sec() break elif server_type == "0": clear() edit_6to4_sec() break else: print("Invalid choice.") def onekharej_one6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m 6TO4 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() iran_qpri_ipsecedit() kharej1_private2_ipsec() break elif server_type == "2": remove_config() enable_reset_ipsec() iran_qpri_ipsecedit() kharej2_private2_ipsec() break elif server_type == "3": remove_config() enable_reset_ipsec() iran_qpri_ipsecedit() kharej3_private2_ipsec() break elif server_type == "4": remove_config() enable_reset_ipsec() iran_qpri_ipsecedit() kharej4_private2_ipsec() break elif server_type == "5": remove_config() enable_reset_ipsec() iran_qpri_ipsecedit() kharej5_private2_ipsec() break elif server_type == "0": clear() oneiran_6to4_sec() break else: print("Invalid choice.") # gre6tap def edit_gre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPV4 Multi \033[0m") print("2. \033[93mGRE6tap Native Multi \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_v4_edit() break elif server_type == "2": gre6tap_v6_edit() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") def gre6tap_v4_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6tap_v4() break elif server_type == "2": oneiran_gre6tap_v4() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[6] Kharej \033[0m") print("7. \033[93m[7] Kharej \033[0m") print("8. \033[93m[8] Kharej \033[0m") print("9. \033[92m[9] Kharej \033[0m") print("10.\033[93m[10] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6_kharejz1() break elif server_type == "2": gre6tap6_kharejz2() break elif server_type == "3": gre6tap6_kharejz3() break elif server_type == "4": gre6tap6_kharejz4() break elif server_type == "5": gre6tap6_kharejz5() break elif server_type == "6": gre6tap6_kharejz6() break elif server_type == "7": gre6tap6_kharejz7() break elif server_type == "8": gre6tap6_kharejz8() break elif server_type == "9": gre6tap6_kharejz9() break elif server_type == "10": gre6tap6_kharejz10() break elif server_type == "11": oneiran_onegre6tap4() break elif server_type == "0": clear() edit_gre6tap() break else: print("Invalid choice.") def oneiran_onegre6tap4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m GRE6tap V4 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9] \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap62_iranz1() break elif server_type == "2": gre6tap62_iranz2() break elif server_type == "3": gre6tap62_iranz3() break elif server_type == "4": gre6tap62_iranz4() break elif server_type == "5": gre6tap62_iranz5() break elif server_type == "6": gre6tap62_iranz6() break elif server_type == "7": gre6tap62_iranz7() break elif server_type == "8": gre6tap62_iranz8() break elif server_type == "9": gre6tap62_iranz9() break elif server_type == "10": gre6tap62_iranz10() break elif server_type == "0": clear() fivekharej_gre6tap_v4() break else: print("Invalid choice.") # gre6tap iran side def oneiran_gre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap6_iranz1() break elif server_type == "2": gre6tap6_iranz2() break elif server_type == "3": gre6tap6_iranz3() break elif server_type == "4": gre6tap6_iranz4() break elif server_type == "5": gre6tap6_iranz5() break elif server_type == "6": onekharej_one_gre6tap4() break elif server_type == "0": clear() edit_gre6tap() break else: print("Invalid choice.") def onekharej_one_gre6tap4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m GRE6tap V4 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap62_kharejz1() break elif server_type == "2": gre6tap62_kharejz2() break elif server_type == "3": gre6tap62_kharejz3() break elif server_type == "4": gre6tap62_kharejz4() break elif server_type == "5": gre6tap62_kharejz5() break elif server_type == "0": clear() oneiran_gre6tap_v4() break else: print("Invalid choice.") # native gre6tap def gre6tap_v6_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6tap_v6() break elif server_type == "2": oneiran_gre6tap_v6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("6. \033[93m[6] Kharej \033[0m") print("7. \033[93m[7] Kharej \033[0m") print("8. \033[93m[8] Kharej \033[0m") print("9. \033[92m[9] Kharej \033[0m") print("10.\033[93m[10] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_k1() break elif server_type == "2": gre6tap_k2() break elif server_type == "3": gre6tap_k3() break elif server_type == "4": gre6tap_k4() break elif server_type == "5": gre6tap_k5() break elif server_type == "6": gre6tap_k6() break elif server_type == "7": gre6tap_k7() break elif server_type == "8": gre6tap_k8() break elif server_type == "9": gre6tap_k9() break elif server_type == "10": gre6tap_k10() break elif server_type == "11": oneiran_onegre6tap6() break elif server_type == "0": clear() edit_gre6tap() break else: print("Invalid choice.") def oneiran_onegre6tap6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m GRE6tap V6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("6. \033[93mServer [6] \033[0m") print("7. \033[93mServer [7] \033[0m") print("8. \033[92mServer [8] \033[0m") print("9. \033[93mServer [9] \033[0m") print("10.\033[93mServer [10] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap2_i1() break elif server_type == "2": gre6tap2_i2() break elif server_type == "3": gre6tap2_i3() break elif server_type == "4": gre6tap2_i4() break elif server_type == "5": gre6tap2_i5() break elif server_type == "6": gre6tap2_i6() break elif server_type == "7": gre6tap2_i7() break elif server_type == "8": gre6tap2_i8() break elif server_type == "9": gre6tap2_i9() break elif server_type == "10": gre6tap2_i10() break elif server_type == "0": clear() fivekharej_gre6tap_v6() break else: print("Invalid choice.") # gre6tap iran side def oneiran_gre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_i1() break elif server_type == "2": gre6tap_i2() break elif server_type == "3": gre6tap_i3() break elif server_type == "4": gre6tap_i4() break elif server_type == "5": gre6tap_i5() break elif server_type == "6": onekharej_one_gre6tap6() break elif server_type == "0": clear() edit_gre6tap() break else: print("Invalid choice.") def onekharej_one_gre6tap6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m GRE6tap V6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap2_k1() break elif server_type == "2": gre6tap2_k2() break elif server_type == "3": gre6tap2_k3() break elif server_type == "4": gre6tap2_k4() break elif server_type == "5": gre6tap2_k5() break elif server_type == "0": clear() oneiran_gre6tap_v6() break else: print("Invalid choice.") # gre6tap + IPsec def edit_gre6tapsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap + IPsec IPV4 Multi \033[0m") print("2. \033[93mGRE6tap + IPsec Native Multi \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_v4sec_edit() break elif server_type == "2": gre6tap_v6sec_edit() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # gre6tap + IPsec native def gre6tap_v6sec_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap + IPsec V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6tapsec_v6() break elif server_type == "2": oneiran_gre6tapsec_v6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Gre6tap V6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap_k11() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap_k21() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap_k31() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap_k41() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap_k51() break elif server_type == "6": oneiran_onegre6tapn_sec() break elif server_type == "0": clear() gre6tap_v6sec_edit() break else: print("Invalid choice.") def oneiran_onegre6tapn_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Gre6tap V6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() irangretap_q1edit() gre6tap2_i11() break elif server_type == "2": remove_config() enable_reset_ipsec() irangretap_q1edit() gre6tap2_i21() break elif server_type == "3": remove_config() enable_reset_ipsec() irangretap_q1edit() gre6tap2_i31() break elif server_type == "4": remove_config() enable_reset_ipsec() irangretap_q1edit() gre6tap2_i41() break elif server_type == "5": remove_config() enable_reset_ipsec() irangretap_q1edit() gre6tap2_i51() break elif server_type == "0": clear() fivekharej_gre6tapsec_v6() break else: print("Invalid choice.") # gre6tap iran side def oneiran_gre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Gre6tap V6 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap_i11() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap_i21() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap_i31() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap_i41() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap_i51() break elif server_type == "6": onekharej_onegre6tapn_sec() break elif server_type == "0": clear() gre6tap_v4sec_edit() break else: print("Invalid choice.") def onekharej_onegre6tapn_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Gre6tap V6 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejgretap_q1edit() gre6tap2_k11() break elif server_type == "2": remove_config() enable_reset_ipsec() kharejgretap_q1edit() gre6tap2_k21() break elif server_type == "3": remove_config() enable_reset_ipsec() kharejgretap_q1edit() gre6tap2_k31() break elif server_type == "4": remove_config() enable_reset_ipsec() kharejgretap_q1edit() gre6tap2_k41() break elif server_type == "5": remove_config() enable_reset_ipsec() kharejgretap_q1edit() gre6tap2_k51() break elif server_type == "0": clear() oneiran_gre6tapsec_v6() break else: print("Invalid choice.") def gre6tap_v4sec_edit(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit GRE6tap + IPsec V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_gre6tapsec_v4() break elif server_type == "2": oneiran_gre6tapsec_v4() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_gre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Gre6tap V4 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap6_kharejz11() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap6_kharejz21() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap6_kharejz31() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap6_kharejz41() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap6_kharejz51() break elif server_type == "6": oneiran_onegre6tap_sec() break elif server_type == "0": clear() gre6tap_v4sec_edit() break else: print("Invalid choice.") def oneiran_onegre6tap_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Gre6tap V4 + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() irangretap4_q1edit() gre6tap62_iranz11() break elif server_type == "2": remove_config() enable_reset_ipsec() irangretap4_q1edit() gre6tap62_iranz21() break elif server_type == "3": remove_config() enable_reset_ipsec() irangretap4_q1edit() gre6tap62_iranz31() break elif server_type == "4": remove_config() enable_reset_ipsec() irangretap4_q1edit() gre6tap62_iranz41() break elif server_type == "5": remove_config() enable_reset_ipsec() irangretap4_q1edit() gre6tap62_iranz51() break elif server_type == "0": clear() fivekharej_gre6tapsec_v4() break else: print("Invalid choice.") # gre6tap iran side def oneiran_gre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Gre6tap V4 + IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() gre6tap6_iranz11() break elif server_type == "2": remove_config() enable_reset_ipsec() gre6tap6_iranz21() break elif server_type == "3": remove_config() enable_reset_ipsec() gre6tap6_iranz31() break elif server_type == "4": remove_config() enable_reset_ipsec() gre6tap6_iranz41() break elif server_type == "5": remove_config() enable_reset_ipsec() gre6tap6_iranz51() break elif server_type == "6": onekharej_onegre6tap_sec() break elif server_type == "0": clear() gre6tap_v4sec_edit() break else: print("Invalid choice.") def onekharej_onegre6tap_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Gre6tap + IPsec Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() kharejgretap4_q1edit() gre6tap62_kharejz11() break elif server_type == "2": remove_config() enable_reset_ipsec() kharejgretap4_q1edit() gre6tap62_kharejz21() break elif server_type == "3": remove_config() enable_reset_ipsec() kharejgretap4_q1edit() gre6tap62_kharejz31() break elif server_type == "4": remove_config() enable_reset_ipsec() kharejgretap4_q1edit() gre6tap62_kharejz41() break elif server_type == "5": remove_config() enable_reset_ipsec() kharejgretap4_q1edit() gre6tap62_kharejz51() break elif server_type == "0": clear() oneiran_gre6tapsec_v4() break else: print("Invalid choice.") # geneve def edit_geneve(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Edit Geneve Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP \033[0m") print("2. \033[93mGeneve + Native\033[0m") print("3. \033[96mGeneve + IPv4 + GRE6\033[0m") print("4. \033[92mGeneve + Native + GRE6\033[0m") print("5. \033[96mGeneve + IPsec\033[0m") print("6. \033[93mGeneve + IPsec + GRE6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_geneve_udp() break elif server_type == "2": edit_geneve_native() break elif server_type == "3": edit_geneve_ipv4g6() break elif server_type == "4": edit_geneve_ipv6g6() break elif server_type == "5": edit_geneve_ipsec() break elif server_type == "6": edit_geneve_gre6sec() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") def edit_geneve_udp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneveudp() break elif server_type == "2": oneiran_geneveudp() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneveudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve Kharej Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5_s1() break elif server_type == "2": kharej5_s2() break elif server_type == "3": kharej5_s3() break elif server_type == "4": kharej5_s4() break elif server_type == "5": kharej5_s5() break elif server_type == "6": oneiran_onegenudp() break elif server_type == "0": clear() edit_geneve_udp() break else: print("Invalid choice.") def oneiran_onegenudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran52_s1() break elif server_type == "2": iran52_s2() break elif server_type == "3": iran52_s3() break elif server_type == "4": iran52_s4() break elif server_type == "5": iran52_s5() break elif server_type == "0": clear() fivekharej_geneveudp() break else: print("Invalid choice.") # geneve iran side def oneiran_geneveudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve IRAN Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran5_s1() break elif server_type == "2": iran5_s2() break elif server_type == "3": iran5_s3() break elif server_type == "4": iran5_s4() break elif server_type == "5": iran5_s5() break elif server_type == "6": onekharej_onegeneveudp() break elif server_type == "0": clear() edit_geneve_udp() break else: print("Invalid choice.") def onekharej_onegeneveudp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej52_s1() break elif server_type == "2": kharej52_s2() break elif server_type == "3": kharej52_s3() break elif server_type == "4": kharej52_s4() break elif server_type == "5": kharej52_s5() break elif server_type == "0": clear() oneiran_geneveudp() break else: print("Invalid choice.") # native geneve def edit_geneve_native(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve Native Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneveudpn() break elif server_type == "2": oneiran_geneveudpn() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneveudpn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Native Geneve Kharej Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej5n_s1() break elif server_type == "2": kharej5n_s2() break elif server_type == "3": kharej5n_s3() break elif server_type == "4": kharej5n_s4() break elif server_type == "5": kharej5n_s5() break elif server_type == "6": oneiran_onegenudpn() break elif server_type == "0": clear() edit_geneve_native() break else: print("Invalid choice.") def oneiran_onegenudpn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran52n_s1() break elif server_type == "2": iran52n_s2() break elif server_type == "3": iran52n_s3() break elif server_type == "4": iran52n_s4() break elif server_type == "5": iran52n_s5() break elif server_type == "0": clear() fivekharej_geneveudpn() break else: print("Invalid choice.") # geneve iran side def oneiran_geneveudpn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Native Geneve IRAN Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran5n_s1() break elif server_type == "2": iran5n_s2() break elif server_type == "3": iran5n_s3() break elif server_type == "4": iran5n_s4() break elif server_type == "5": iran5n_s5() break elif server_type == "6": onekharej_onegeneveudpn() break elif server_type == "0": clear() edit_geneve_native() break else: print("Invalid choice.") def onekharej_onegeneveudpn(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej52n_s1() break elif server_type == "2": kharej52n_s2() break elif server_type == "3": kharej52n_s3() break elif server_type == "4": kharej52n_s4() break elif server_type == "5": kharej52n_s5() break elif server_type == "0": clear() oneiran_geneveudpn() break else: print("Invalid choice.") # geneve ipv4 gre6 def edit_geneve_ipv4g6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve + GRE6 V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_gre6v4() break elif server_type == "2": oneiran_geneve_gre6v4() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_gre6v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 V4 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_kharej_gre1() break elif server_type == "2": genp4_kharej_gre2() break elif server_type == "3": genp4_kharej_gre3() break elif server_type == "4": genp4_kharej_gre4() break elif server_type == "5": genp4_kharej_gre5() break elif server_type == "6": oneiran_onegen_gre6v4() break elif server_type == "0": clear() edit_geneve_ipv4g6() break else: print("Invalid choice.") def oneiran_onegen_gre6v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_iran2_gre1() break elif server_type == "2": genp4_iran2_gre2() break elif server_type == "3": genp4_iran2_gre3() break elif server_type == "4": genp4_iran2_gre4() break elif server_type == "5": genp4_iran2_gre5() break elif server_type == "0": clear() fivekharej_geneve_gre6v4() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_gre6v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 V4 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_iran_gre1() break elif server_type == "2": genp4_iran_gre2() break elif server_type == "3": genp4_iran_gre3() break elif server_type == "4": genp4_iran_gre4() break elif server_type == "5": genp4_iran_gre5() break elif server_type == "6": onekharej_onegeneve_gre6v4() break elif server_type == "0": clear() edit_geneve_ipv4g6() break else: print("Invalid choice.") def onekharej_onegeneve_gre6v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genp4_kharej2_gre1() break elif server_type == "2": genp4_kharej2_gre2() break elif server_type == "3": genp4_kharej2_gre3() break elif server_type == "4": genp4_kharej2_gre4() break elif server_type == "5": genp4_kharej2_gre5() break elif server_type == "0": clear() oneiran_geneve_gre6v4() break else: print("Invalid choice.") # geneve gre6 v6 def edit_geneve_ipv6g6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve + GRE6 V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_gre6v6() break elif server_type == "2": oneiran_geneve_gre6v6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_gre6v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 V6 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_kharej_gre1() break elif server_type == "2": gen_kharej_gre2() break elif server_type == "3": gen_kharej_gre3() break elif server_type == "4": gen_kharej_gre4() break elif server_type == "5": gen_kharej_gre5() break elif server_type == "6": oneiran_onegen_gre6v6() break elif server_type == "0": clear() edit_geneve_ipv6g6() break else: print("Invalid choice.") def oneiran_onegen_gre6v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_iran2_gre1() break elif server_type == "2": gen_iran2_gre2() break elif server_type == "3": gen_iran2_gre3() break elif server_type == "4": gen_iran2_gre4() break elif server_type == "5": gen_iran2_gre5() break elif server_type == "0": clear() fivekharej_geneve_gre6v6() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_gre6v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 V6 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_iran_gre1() break elif server_type == "2": gen_iran_gre2() break elif server_type == "3": gen_iran_gre3() break elif server_type == "4": gen_iran_gre4() break elif server_type == "5": gen_iran_gre5() break elif server_type == "6": onekharej_onegeneve_gre6v6() break elif server_type == "0": clear() edit_geneve_ipv6g6() break else: print("Invalid choice.") def onekharej_onegeneve_gre6v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_kharej2_gre1() break elif server_type == "2": gen_kharej2_gre2() break elif server_type == "3": gen_kharej2_gre3() break elif server_type == "4": gen_kharej2_gre4() break elif server_type == "5": gen_kharej2_gre5() break elif server_type == "0": clear() oneiran_geneve_gre6v6() break else: print("Invalid choice.") # geneve ipsec def edit_geneve_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGeneve + IPsec \033[93mMulti Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGen IPsec IPV4 \033[0m") print("2. \033[93mGen IPsec Native\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_gensec_ipv4() break elif server_type == "2": edit_gensec_ipv6() break elif server_type == "0": clear() edit_geneve() break else: print("Invalid choice.") def edit_gensec_ipv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve + IPsec V4 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_secv4() break elif server_type == "2": oneiran_geneve_secv4() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + IPsec V4 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() kharej5_s1() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() kharej5_s2() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() kharej5_s3() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() kharej5_s4() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() kharej5_s5() break elif server_type == "6": oneiran_onegen_secv4() break elif server_type == "0": clear() edit_gensec_ipv4() break else: print("Invalid choice.") def oneiran_onegen_secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran11_ipsec_genedit() iran52_s1() break elif server_type == "2": iran11_ipsec_genedit() iran52_s2() break elif server_type == "3": iran11_ipsec_genedit() iran52_s3() break elif server_type == "4": iran11_ipsec_genedit() iran52_s4() break elif server_type == "5": iran11_ipsec_genedit() iran52_s5() break elif server_type == "0": clear() fivekharej_geneve_secv4() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + IPsec V4 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() iran5_s1() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() iran5_s2() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() iran5_s3() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() iran5_s4() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() iran5_s5() break elif server_type == "6": onekharej_onegeneve_secv4() break elif server_type == "0": clear() edit_gensec_ipv4() break else: print("Invalid choice.") def onekharej_onegeneve_secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej11_ipsec_genedit() kharej52_s1() break elif server_type == "2": kharej11_ipsec_genedit() kharej52_s2() break elif server_type == "3": kharej11_ipsec_genedit() kharej52_s3() break elif server_type == "4": kharej11_ipsec_genedit() kharej52_s4() break elif server_type == "5": kharej11_ipsec_genedit() kharej52_s5() break elif server_type == "0": clear() oneiran_geneve_secv4() break else: print("Invalid choice.") # geneve native ipsec def edit_gensec_ipv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mEdit Geneve + IPsec V6 Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_secv6() break elif server_type == "2": oneiran_geneve_secv6() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + IPsec V6 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() kharej5n_s1() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() kharej5n_s2() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() kharej5n_s3() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() kharej5n_s4() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() kharej5n_s5() break elif server_type == "6": oneiran_onegen_secv6() break elif server_type == "0": clear() edit_gensec_ipv6() break else: print("Invalid choice.") def oneiran_onegen_secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1_ipsecn_genedit() iran52n_s1() break elif server_type == "2": iran1_ipsecn_genedit() iran52n_s2() break elif server_type == "3": iran1_ipsecn_genedit() iran52n_s3() break elif server_type == "4": iran1_ipsecn_genedit() iran52n_s4() break elif server_type == "5": iran1_ipsecn_genedit() iran52n_s5() break elif server_type == "0": clear() fivekharej_geneve_secv6() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + IPsec V6 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() iran5n_s1() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() iran5n_s2() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() iran5n_s3() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() iran5n_s4() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() iran5n_s5() break elif server_type == "6": onekharej_onegeneve_secv6() break elif server_type == "0": clear() edit_gensec_ipv6() break else: print("Invalid choice.") def onekharej_onegeneve_secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_ipsecn_genedit() kharej52n_s1() break elif server_type == "2": kharej1_ipsecn_genedit() kharej52n_s2() break elif server_type == "3": kharej1_ipsecn_genedit() kharej52n_s3() break elif server_type == "4": kharej1_ipsecn_genedit() kharej52n_s4() break elif server_type == "5": kharej1_ipsecn_genedit() kharej52n_s5() break elif server_type == "0": clear() oneiran_geneve_secv6() break else: print("Invalid choice.") # geneve + gre6 + ipsec def edit_geneve_gre6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[96mGeneve GRE6 + IPsec \033[93mMulti Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGen IPsec GRE6 IPV4 \033[0m") print("2. \033[93mGen IPsec GRE6 Native\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_gensec_gre6ipv4() break elif server_type == "2": edit_gensec_gre6ipv6() break elif server_type == "0": clear() edit_geneve() break else: print("Invalid choice.") def edit_gensec_gre6ipv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve Gre6 + IPsec V4 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_gre6secv4() break elif server_type == "2": oneiran_geneve_gre6secv4() break elif server_type == "0": clear() edit_geneve_gre6sec() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_gre6secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve GRE6 + IPsec V4 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() genp4_kharej_gre1() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() genp4_kharej_gre2() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() genp4_kharej_gre3() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() genp4_kharej_gre4() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() genp4_kharej_gre5() break elif server_type == "6": oneiran_onegen_gre6secv4() break elif server_type == "0": clear() edit_gensec_gre6ipv4() break else: print("Invalid choice.") def oneiran_onegen_gre6secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Gre6 Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iranp4_ipsec_questione() genp4_iran2_gre1() break elif server_type == "2": iranp4_ipsec_questione() genp4_iran2_gre2() break elif server_type == "3": iranp4_ipsec_questione() genp4_iran2_gre3() break elif server_type == "4": iranp4_ipsec_questione() genp4_iran2_gre4() break elif server_type == "5": iranp4_ipsec_questione() genp4_iran2_gre5() break elif server_type == "0": clear() fivekharej_geneve_gre6secv4() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_gre6secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 IPsec V4 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() genp4_iran_gre1() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() genp4_iran_gre2() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() genp4_iran_gre3() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() genp4_iran_gre4() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() genp4_iran_gre5() break elif server_type == "6": onekharej_onegeneve_gre6secv4() break elif server_type == "0": clear() edit_gensec_gre6ipv4() break else: print("Invalid choice.") def onekharej_onegeneve_gre6secv4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejp4_ipsec_questione() genp4_kharej2_gre1() break elif server_type == "2": kharejp4_ipsec_questione() genp4_kharej2_gre2() break elif server_type == "3": kharejp4_ipsec_questione() genp4_kharej2_gre3() break elif server_type == "4": kharejp4_ipsec_questione() genp4_kharej2_gre4() break elif server_type == "5": kharejp4_ipsec_questione() genp4_kharej2_gre5() break elif server_type == "0": clear() oneiran_geneve_gre6secv4() break else: print("Invalid choice.") # native gre6 ipsec def edit_gensec_gre6ipv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve Gre6 + IPsec V6 Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5] Kharej [1] IRAN \033[0m") print("2. \033[93m[1] Kharej [5] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": fivekharej_geneve_gre6secv6() break elif server_type == "2": oneiran_geneve_gre6secv6() break elif server_type == "0": clear() edit_geneve_gre6sec() break else: print("Invalid choice.") # kharej side def fivekharej_geneve_gre6secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve GRE6 + IPsec V6 Kharej Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] Kharej \033[0m") print("2. \033[93m[2] Kharej \033[0m") print("3. \033[93m[3] Kharej \033[0m") print("4. \033[92m[4] Kharej \033[0m") print("5. \033[93m[5] Kharej \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] IRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() new1() gen_kharej_gre1() break elif server_type == "2": remove_config() enable_reset_ipsec() new2() gen_kharej_gre2() break elif server_type == "3": remove_config() enable_reset_ipsec() new3() gen_kharej_gre3() break elif server_type == "4": remove_config() enable_reset_ipsec() new4() gen_kharej_gre4() break elif server_type == "5": remove_config() enable_reset_ipsec() new5() gen_kharej_gre5() break elif server_type == "6": oneiran_onegen_gre6secv6() break elif server_type == "0": clear() edit_gensec_gre6ipv6() break else: print("Invalid choice.") def oneiran_onegen_gre6secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mIRAN\033[92m Gre6 Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran_ipsecz_questione() gen_iran2_gre1() break elif server_type == "2": iran_ipsecz_questione() gen_iran2_gre2() break elif server_type == "3": iran_ipsecz_questione() gen_iran2_gre3() break elif server_type == "4": iran_ipsecz_questione() gen_iran2_gre4() break elif server_type == "5": iran_ipsecz_questione() gen_iran2_gre5() break elif server_type == "0": clear() fivekharej_geneve_gre6secv6() break else: print("Invalid choice.") # geneve iran side def oneiran_geneve_gre6secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit Geneve + GRE6 IPsec V6 IRAN Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93m[1] IRAN \033[0m") print("2. \033[93m[2] IRAN \033[0m") print("3. \033[93m[3] IRAN \033[0m") print("4. \033[92m[4] IRAN \033[0m") print("5. \033[93m[5] IRAN \033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6. \033[93m[1] Kharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_config() enable_reset_ipsec() newi1() gen_iran_gre1() break elif server_type == "2": remove_config() enable_reset_ipsec() newi2() gen_iran_gre2() break elif server_type == "3": remove_config() enable_reset_ipsec() newi3() gen_iran_gre3() break elif server_type == "4": remove_config() enable_reset_ipsec() newi4() gen_iran_gre4() break elif server_type == "5": remove_config() enable_reset_ipsec() newi5() gen_iran_gre5() break elif server_type == "6": onekharej_onegeneve_gre6secv6() break elif server_type == "0": clear() edit_gensec_gre6ipv6() break else: print("Invalid choice.") def onekharej_onegeneve_gre6secv6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mEdit \033[96mKharej\033[92m Geneve[IPsec] Servers\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[93mServer [1] \033[0m") print("2. \033[93mServer [2] \033[0m") print("3. \033[92mServer [3] \033[0m") print("4. \033[93mServer [4] \033[0m") print("5. \033[93mServer [5] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_ipsecz_questione() gen_kharej2_gre1() break elif server_type == "2": kharej_ipsecz_questione() gen_kharej2_gre2() break elif server_type == "3": kharej_ipsecz_questione() gen_kharej2_gre3() break elif server_type == "4": kharej_ipsecz_questione() gen_kharej2_gre4() break elif server_type == "5": kharej_ipsecz_questione() gen_kharej2_gre5() break elif server_type == "0": clear() oneiran_geneve_gre6secv6() break else: print("Invalid choice.") # remove def removemenu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mRemove Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIP6IP6 \033[0m") print("2. \033[92mIP6IP6 + IPSec \033[0m") print("3. \033[93mGRE6 \033[0m") print("4. \033[93mGRE6 + IPSec \033[0m") print("5. \033[96m6to4 \033[0m") print("6. \033[96m6to4 + IPSec \033[0m") print("7. \033[92mGRE6tap \033[0m") print("8. \033[92mGRE6tap + IPsec \033[0m") print("9. \033[93mGeneve [IPsec included] \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editremove_ip6ip6() break elif server_type == "2": editremove_ip6ip6_sec() break elif server_type == "3": editremove_gre6() break elif server_type == "4": editremove_gre6_sec() break elif server_type == "5": editremove_6to4() break elif server_type == "6": editremove_6to4_sec() break elif server_type == "7": editremove_gre6tap() break elif server_type == "8": editremove_gre6tapsec() break elif server_type == "9": editremove_geneve() break elif server_type == "0": clear() edit_server() break else: print("Invalid choice.") # remove ip6ip6 def editremove_ip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [10]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_ipip6() break elif server_type == "2": editir_ipip6() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "11": edit_iranip6ip6() break elif server_type == "0": clear() editremove_ip6ip6() break else: print("Invalid choice.") def edit_iranip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("6. \033[92mIRAN-Tunnel[6]\033[0m") print("7. \033[92mIRAN-Tunnel[7]\033[0m") print("8. \033[93mIRAN-Tunnel[8]\033[0m") print("9. \033[92mIRAN-Tunnel[9]\033[0m") print("10.\033[92mIRAN-Tunnel[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "0": clear() editkh_ipip6() break else: print("Invalid choice.") def editir_ipip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 [10]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("6. \033[92mIRAN[6]\033[0m") print("7. \033[92mIRAN[7]\033[0m") print("8. \033[93mIRAN[8]\033[0m") print("9. \033[92mIRAN[9]\033[0m") print("10.\033[92mIRAN[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "11": edit_kharejip6ip6() break elif server_type == "0": clear() editremove_ip6ip6() break else: print("Invalid choice.") def edit_kharejip6ip6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("6. \033[92mKharej-Tunnel[6]\033[0m") print("7. \033[92mKharej-Tunnel[7]\033[0m") print("8. \033[93mKharej-Tunnel[8]\033[0m") print("9. \033[92mKharej-Tunnel[9]\033[0m") print("10.\033[92mKharej-Tunnel[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": remove_ipip66() break elif server_type == "7": remove_ipip67() break elif server_type == "8": remove_ipip68() break elif server_type == "9": remove_ipip69() break elif server_type == "10": remove_ipip610() break elif server_type == "0": clear() editir_ipip6() break else: print("Invalid choice.") # ip6ip6 + sec remove def editremove_ip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_ipip6_sec() break elif server_type == "2": editir_ipip6_sec() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_ipip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61_sec() break elif server_type == "2": remove_ipip62_sec() break elif server_type == "3": remove_ipip63_sec() break elif server_type == "4": remove_ipip64_sec() break elif server_type == "5": remove_ipip65_sec() break elif server_type == "6": edit_iranip6ip6_sec() break elif server_type == "0": clear() editremove_ip6ip6_sec() break else: print("Invalid choice.") def edit_iranip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() kharejip_qsecedit2() break elif server_type == "2": remove_ipip62() kharejip_qsecedit2() break elif server_type == "3": remove_ipip63() kharejip_qsecedit2() break elif server_type == "4": remove_ipip64() kharejip_qsecedit2() break elif server_type == "5": remove_ipip65() kharejip_qsecedit2() break elif server_type == "0": clear() editkh_ipip6_sec() break else: print("Invalid choice.") def editir_ipip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() break elif server_type == "2": remove_ipip62() break elif server_type == "3": remove_ipip63() break elif server_type == "4": remove_ipip64() break elif server_type == "5": remove_ipip65() break elif server_type == "6": edit_kharejip6ip6_sec() break elif server_type == "0": clear() editremove_ip6ip6_sec() break else: print("Invalid choice.") def edit_kharejip6ip6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m IP6IP6 + IPsec Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip61() iranip_qsecedit2() break elif server_type == "2": remove_ipip62() iranip_qsecedit2() break elif server_type == "3": remove_ipip63() iranip_qsecedit2() break elif server_type == "4": remove_ipip64() iranip_qsecedit2() break elif server_type == "5": remove_ipip65() iranip_qsecedit2() break elif server_type == "0": clear() editir_ipip6_sec() break else: print("Invalid choice.") # remove gre6 def editremove_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6() break elif server_type == "2": editir_gre6() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "6": remove_gre66() break elif server_type == "7": remove_gre67() break elif server_type == "8": remove_gre68() break elif server_type == "9": remove_gre69() break elif server_type == "10": remove_gre610() break elif server_type == "11": edit_irangre6() break elif server_type == "0": clear() editremove_gre6() break else: print("Invalid choice.") def edit_irangre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("6. \033[92mIRAN-Tunnel[6]\033[0m") print("7. \033[92mIRAN-Tunnel[7]\033[0m") print("8. \033[93mIRAN-Tunnel[8]\033[0m") print("9. \033[92mIRAN-Tunnel[9]\033[0m") print("10.\033[92mIRAN-Tunnel[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "6": remove_gre66() break elif server_type == "7": remove_gre67() break elif server_type == "8": remove_gre68() break elif server_type == "9": remove_gre69() break elif server_type == "10": remove_gre610() break elif server_type == "0": clear() editkh_gre6() break else: print("Invalid choice.") def editir_gre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "6": edit_kharejgre6() break elif server_type == "0": clear() editremove_gre6() break else: print("Invalid choice.") def edit_kharejgre6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61() break elif server_type == "2": remove_gre62() break elif server_type == "3": remove_gre63() break elif server_type == "4": remove_gre64() break elif server_type == "5": remove_gre65() break elif server_type == "0": clear() editir_gre6() break else: print("Invalid choice.") # gre6 ipsec def editremove_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 + IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6_sec() break elif server_type == "2": editir_gre6_sec() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 | IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() break elif server_type == "2": remove_gre62_ipsec() break elif server_type == "3": remove_gre63_ipsec() break elif server_type == "4": remove_gre64_ipsec() break elif server_type == "5": remove_gre65_ipsec() break elif server_type == "6": edit_irangre6_sec() break elif server_type == "0": clear() editremove_gre6_sec() break else: print("Invalid choice.") def edit_irangre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 | IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() kharejgre_qipsec_edit2() break elif server_type == "2": remove_gre62_ipsec() kharejgre_qipsec_edit2() break elif server_type == "3": remove_gre63_ipsec() kharejgre_qipsec_edit2() break elif server_type == "4": remove_gre64_ipsec() kharejgre_qipsec_edit2() break elif server_type == "5": remove_gre65_ipsec() kharejgre_qipsec_edit2() break elif server_type == "0": clear() editkh_gre6_sec() break else: print("Invalid choice.") def editir_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 | IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() break elif server_type == "2": remove_gre62_ipsec() break elif server_type == "3": remove_gre63_ipsec() break elif server_type == "4": remove_gre64_ipsec() break elif server_type == "5": remove_gre65_ipsec() break elif server_type == "6": edit_kharejgre6_sec() break elif server_type == "0": clear() editremove_gre6_sec() break else: print("Invalid choice.") def edit_kharejgre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m GRE6 | IPsec Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gre61_ipsec() irangre_qipsec_edit2() break elif server_type == "2": remove_gre62_ipsec() irangre_qipsec_edit2() break elif server_type == "3": remove_gre63_ipsec() irangre_qipsec_edit2() break elif server_type == "4": remove_gre64_ipsec() irangre_qipsec_edit2() break elif server_type == "5": remove_gre65_ipsec() irangre_qipsec_edit2() break elif server_type == "0": clear() editir_gre6_sec() break else: print("Invalid choice.") # 6to4 remove def editremove_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_6to4() break elif server_type == "2": editir_6to4() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "6": remove_private6() break elif server_type == "7": remove_private7() break elif server_type == "8": remove_private8() break elif server_type == "9": remove_private9() break elif server_type == "10": remove_private10() break elif server_type == "11": edit_iran6to4() break elif server_type == "0": clear() editremove_6to4() break else: print("Invalid choice.") def edit_iran6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("6. \033[92mIRAN-Tunnel[6]\033[0m") print("7. \033[92mIRAN-Tunnel[7]\033[0m") print("8. \033[93mIRAN-Tunnel[8]\033[0m") print("9. \033[92mIRAN-Tunnel[9]\033[0m") print("10.\033[92mIRAN-Tunnel[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "6": remove_private6() break elif server_type == "7": remove_private7() break elif server_type == "8": remove_private8() break elif server_type == "9": remove_private9() break elif server_type == "10": remove_private10() break elif server_type == "0": clear() editkh_6to4() break else: print("Invalid choice.") def editir_6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "6": edit_kharej6to4() break elif server_type == "0": clear() editremove_6to4() break else: print("Invalid choice.") def edit_kharej6to4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1() break elif server_type == "2": remove_private2() break elif server_type == "3": remove_private3() break elif server_type == "4": remove_private4() break elif server_type == "5": remove_private5() break elif server_type == "0": clear() editir_6to4() break else: print("Invalid choice.") # 6to4 ipsec def editremove_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 | IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_6to4_sec() break elif server_type == "2": editir_6to4_sec() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def editkh_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 | IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() break elif server_type == "2": remove_private2_sec() break elif server_type == "3": remove_private3_sec() break elif server_type == "4": remove_private4_sec() break elif server_type == "5": remove_private5_sec() break elif server_type == "6": edit_iran6to4_sec() break elif server_type == "0": clear() editremove_6to4_sec() break else: print("Invalid choice.") def edit_iran6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() kharej_qpri_ipsecedit2() break elif server_type == "2": remove_private2_sec() kharej_qpri_ipsecedit2() break elif server_type == "3": remove_private3_sec() kharej_qpri_ipsecedit2() break elif server_type == "4": remove_private4_sec() kharej_qpri_ipsecedit2() break elif server_type == "5": remove_private5_sec() kharej_qpri_ipsecedit2() break elif server_type == "0": clear() editkh_6to4_sec() break else: print("Invalid choice.") def editir_6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() break elif server_type == "2": remove_private2_sec() break elif server_type == "3": remove_private3_sec() break elif server_type == "4": remove_private4_sec() break elif server_type == "5": remove_private5_sec() break elif server_type == "6": edit_kharej6to4_sec() break elif server_type == "0": clear() editremove_6to4_sec() break else: print("Invalid choice.") def edit_kharej6to4_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m 6TO4 IPsec Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_private1_sec() iran_qpri_ipsecedit2() break elif server_type == "2": remove_private2_sec() iran_qpri_ipsecedit2() break elif server_type == "3": remove_private3_sec() iran_qpri_ipsecedit2() break elif server_type == "4": remove_private4_sec() iran_qpri_ipsecedit2() break elif server_type == "5": remove_private5_sec() iran_qpri_ipsecedit2() break elif server_type == "0": clear() editir_6to4_sec() break else: print("Invalid choice.") # gretap ipv4 def editremove_gre6tap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mRemove GRE6tap Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPV4 Multi \033[0m") print("2. \033[93mGRE6tap Native Multi \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tap_v4_editrmv() break elif server_type == "2": gre6tap_v6_editrmv() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def gre6tap_v4_editrmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V4\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6tap_v4() break elif server_type == "2": editir_gre6tap_v4() break elif server_type == "0": clear() editremove_gre6tap() break else: print("Invalid choice.") def editkh_gre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V4 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": remove_gretap66() break elif server_type == "7": remove_gretap67() break elif server_type == "8": remove_gretap68() break elif server_type == "9": remove_gretap69() break elif server_type == "10": remove_gretap610() break elif server_type == "11": edit_irangre6tap_v4() break elif server_type == "0": clear() gre6tap_v4_editrmv() break else: print("Invalid choice.") def edit_irangre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": remove_gretap66() break elif server_type == "7": remove_gretap67() break elif server_type == "8": remove_gretap68() break elif server_type == "9": remove_gretap69() break elif server_type == "10": remove_gretap610() break elif server_type == "0": clear() editkh_gre6tap_v4() break else: print("Invalid choice.") def editir_gre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V4 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": edit_kharejgre6tap_v4() break elif server_type == "0": clear() gre6tap_v4_editrmv() break else: print("Invalid choice.") def edit_kharejgre6tap_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V4 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "0": clear() editir_gre6tap_v4() break else: print("Invalid choice.") # gre6tap v6 def gre6tap_v6_editrmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6tap_v6() break elif server_type == "2": editir_gre6tap_v6() break elif server_type == "0": clear() editremove_gre6tap() break else: print("Invalid choice.") def editkh_gre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V6 [10]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("6. \033[92mKharej[6]\033[0m") print("7. \033[92mKharej[7]\033[0m") print("8. \033[93mKharej[8]\033[0m") print("9. \033[92mKharej[9]\033[0m") print("10.\033[92mKharej[10]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": remove_gretap66() break elif server_type == "7": remove_gretap67() break elif server_type == "8": remove_gretap68() break elif server_type == "9": remove_gretap69() break elif server_type == "10": remove_gretap610() break elif server_type == "11": edit_irangre6tap_v6() break elif server_type == "0": clear() gre6tap_v6_editrmv() break else: print("Invalid choice.") def edit_irangre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("6. \033[92mServer[6]\033[0m") print("7. \033[92mServer[7]\033[0m") print("8. \033[93mServer[8]\033[0m") print("9. \033[92mServer[9]\033[0m") print("10.\033[92mServer[10]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": remove_gretap66() break elif server_type == "7": remove_gretap67() break elif server_type == "8": remove_gretap68() break elif server_type == "9": remove_gretap69() break elif server_type == "10": remove_gretap610() break elif server_type == "0": clear() editkh_gre6tap_v6() break else: print("Invalid choice.") def editir_gre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "6": edit_kharejgre6tap_v6() break elif server_type == "0": clear() gre6tap_v6_editrmv() break else: print("Invalid choice.") def edit_kharejgre6tap_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V6 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61() break elif server_type == "2": remove_gretap62() break elif server_type == "3": remove_gretap63() break elif server_type == "4": remove_gretap64() break elif server_type == "5": remove_gretap65() break elif server_type == "0": clear() editir_gre6tap_v6() break else: print("Invalid choice.") # gre6tap ipsec v4 def editremove_gre6tapsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mRemove GRE6tap IPsec Servers\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE6tap IPsec IPV4 Multi \033[0m") print("2. \033[93mGRE6tap IPsec Native Multi \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6tapsec_v4_editrmv() break elif server_type == "2": gre6tapsec_v6_editrmv() break elif server_type == "0": clear() removemenu() break else: print("Invalid choice.") def gre6tapsec_v4_editrmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V4\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6tapsec_v4() break elif server_type == "2": editir_gre6tapsec_v4() break elif server_type == "0": clear() editremove_gre6tapsec() break else: print("Invalid choice.") def editkh_gre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V4 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": edit_irangre6tapsec_v4() break elif server_type == "0": clear() gre6tapsec_v4_editrmv() break else: print("Invalid choice.") def edit_irangre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() irangretap4_q1edit2() break elif server_type == "2": remove_gretap62_sec() irangretap4_q1edit2() break elif server_type == "3": remove_gretap63_sec() irangretap4_q1edit2() break elif server_type == "4": remove_gretap64_sec() irangretap4_q1edit2() break elif server_type == "5": remove_gretap65_sec() irangretap4_q1edit2() break elif server_type == "0": clear() editkh_gre6tapsec_v4() break else: print("Invalid choice.") def editir_gre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V4 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": edit_kharejgre6tapsec_v4() break elif server_type == "0": clear() gre6tapsec_v4_editrmv() break else: print("Invalid choice.") def edit_kharejgre6tapsec_v4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V4 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() kharejgretap4_q1edit2() break elif server_type == "2": remove_gretap62_sec() kharejgretap4_q1edit2() break elif server_type == "3": remove_gretap63_sec() kharejgretap4_q1edit2() break elif server_type == "4": remove_gretap64_sec() kharejgretap4_q1edit2() break elif server_type == "5": remove_gretap65_sec() kharejgretap4_q1edit2() break elif server_type == "0": clear() editir_gre6tapsec_v4() break else: print("Invalid choice.") # gre6tap ipsec v6 def gre6tapsec_v6_editrmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gre6tapsec_v6() break elif server_type == "2": editir_gre6tapsec_v6() break elif server_type == "0": clear() editremove_gre6tapsec() break else: print("Invalid choice.") def editkh_gre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V6 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": edit_irangre6tapsec_v6() break elif server_type == "0": clear() gre6tapsec_v6_editrmv() break else: print("Invalid choice.") def edit_irangre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() irangretap_q1edit2() break elif server_type == "2": remove_gretap62_sec() irangretap_q1edit2() break elif server_type == "3": remove_gretap63_sec() irangretap_q1edit2() break elif server_type == "4": remove_gretap64_sec() irangretap_q1edit2() break elif server_type == "5": remove_gretap65_sec() irangretap_q1edit2() break elif server_type == "0": clear() editkh_gre6tapsec_v6() break else: print("Invalid choice.") def editir_gre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap IPsec V6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() break elif server_type == "2": remove_gretap62_sec() break elif server_type == "3": remove_gretap63_sec() break elif server_type == "4": remove_gretap64_sec() break elif server_type == "5": remove_gretap65_sec() break elif server_type == "6": edit_kharejgre6tapsec_v6() break elif server_type == "0": clear() gre6tapsec_v6_editrmv() break else: print("Invalid choice.") def edit_kharejgre6tapsec_v6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Gre6tap V6 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mServer[1]\033[0m") print("2. \033[92mServer[2]\033[0m") print("3. \033[93mServer[3]\033[0m") print("4. \033[92mServer[4]\033[0m") print("5. \033[92mServer[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_gretap61_sec() kharejgretap_q1edit2() break elif server_type == "2": remove_gretap62_sec() kharejgretap_q1edit2() break elif server_type == "3": remove_gretap63_sec() kharejgretap_q1edit2() break elif server_type == "4": remove_gretap64_sec() kharejgretap_q1edit2() break elif server_type == "5": remove_gretap65_sec() kharejgretap_q1edit2() break elif server_type == "0": clear() editir_gre6tapsec_v6() break else: print("Invalid choice.") # geneve remove def editremove_geneve(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m Remove Geneve Multi Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP \033[0m") print("2. \033[93mGeneve + Native\033[0m") print("3. \033[96mGeneve + IPv4 + GRE6\033[0m") print("4. \033[92mGeneve + Native + GRE6\033[0m") print("5. \033[96mGeneve + IPsec\033[0m") print("6. \033[93mGeneve + IPsec + GRE6\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editrmv_geneve_udp() break elif server_type == "2": editrmv_geneve_native() break elif server_type == "3": editrmv_geneve_ipv4g6() break elif server_type == "4": editrmv_geneve_ipv6g6() break elif server_type == "5": editrmv_geneve_ipsec() break elif server_type == "6": editrmv_geneve_gre6sec() break elif server_type == "0": clear() editmenu() break else: print("Invalid choice.") # geneve udp remove def editrmv_geneve_udp(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_genudp_rmv() break elif server_type == "2": editir_genudp_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def editkh_genudp_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": edit_irangenudp_rmv() break elif server_type == "0": clear() editrmv_geneve_udp() break else: print("Invalid choice.") def edit_irangenudp_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "0": clear() editkh_genudp_rmv() break else: print("Invalid choice.") def editir_genudp_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": edit_kharejgenudp_rmv() break elif server_type == "0": clear() editrmv_geneve_udp() break else: print("Invalid choice.") def edit_kharejgenudp_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "0": clear() editir_genudp_rmv() break else: print("Invalid choice.") # geneve native def editrmv_geneve_native(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Native\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_genudpn_rmv() break elif server_type == "2": editir_genudpn_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def editkh_genudpn_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Native [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": edit_irangenudpn_rmv() break elif server_type == "0": clear() editrmv_geneve_native() break else: print("Invalid choice.") def edit_irangenudpn_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Native IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "0": clear() editkh_genudpn_rmv() break else: print("Invalid choice.") def editir_genudpn_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Native [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "6": edit_kharejgenudpn_rmv() break elif server_type == "0": clear() editrmv_geneve_native() break else: print("Invalid choice.") def edit_kharejgenudpn_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Native Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall() break elif server_type == "2": genz2_uninstall() break elif server_type == "3": genz3_uninstall() break elif server_type == "4": genz4_uninstall() break elif server_type == "5": genz5_uninstall() break elif server_type == "0": clear() editir_genudpn_rmv() break else: print("Invalid choice.") # geneve gre6 v4 def editrmv_geneve_ipv4g6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gengrev4_rmv() break elif server_type == "2": editir_gengrev4_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def editkh_gengrev4_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": edit_irangengrev4_rmv() break elif server_type == "0": clear() editrmv_geneve_ipv4g6() break else: print("Invalid choice.") def edit_irangengrev4_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4 IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "0": clear() editkh_gengrev4_rmv() break else: print("Invalid choice.") def editir_gengrev4_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": edit_kharejgengrev4_rmv() break elif server_type == "0": clear() editrmv_geneve_ipv4g6() break else: print("Invalid choice.") def edit_kharejgengrev4_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "0": clear() editir_gengrev4_rmv() break else: print("Invalid choice.") # gen gre6 v6 def editrmv_geneve_ipv6g6(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V6\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gengrev6_rmv() break elif server_type == "2": editir_gengrev6_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def editkh_gengrev6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V6 [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": edit_irangengrev6_rmv() break elif server_type == "0": clear() editrmv_geneve_ipv6g6() break else: print("Invalid choice.") def edit_irangengrev6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V6 IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "0": clear() editkh_gengrev6_rmv() break else: print("Invalid choice.") def editir_gengrev6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V6 [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "6": edit_kharejgengrev6_rmv() break elif server_type == "0": clear() editrmv_geneve_ipv6g6() break else: print("Invalid choice.") def edit_kharejgengrev6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V6 Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1gre_uninstall() break elif server_type == "2": genz2gre_uninstall() break elif server_type == "3": genz3gre_uninstall() break elif server_type == "4": genz4gre_uninstall() break elif server_type == "5": genz5gre_uninstall() break elif server_type == "0": clear() editir_gengrev6_rmv() break else: print("Invalid choice.") # geneve ipsec udp def editrmv_geneve_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP + IPsec\033[0m") print("2. \033[93mGeneve Native + IPsec\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_genudpsec_rmv() break elif server_type == "2": edit_gennativesec_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def edit_genudpsec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Udp IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_genudpsec_rmv() break elif server_type == "2": editir_genudpsec_rmv() break elif server_type == "0": clear() editrmv_geneve_ipsec() break else: print("Invalid choice.") def editkh_genudpsec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() break elif server_type == "2": genz2u_uninstall_sec() break elif server_type == "3": genz3u_uninstall_sec() break elif server_type == "4": genz4u_uninstall_sec() break elif server_type == "5": genz5u_uninstall_sec() break elif server_type == "6": edit_irangenudpsec_rmv() break elif server_type == "0": clear() edit_genudpsec_rmv() break else: print("Invalid choice.") def edit_irangenudpsec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "2": genz2u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "3": genz3u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "4": genz4u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "5": genz5u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "0": clear() editkh_genudpsec_rmv() break else: print("Invalid choice.") def editir_genudpsec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() break elif server_type == "2": genz2u_uninstall_sec() break elif server_type == "3": genz3u_uninstall_sec() break elif server_type == "4": genz4u_uninstall_sec() break elif server_type == "5": genz5u_uninstall_sec() break elif server_type == "6": edit_kharejgenudpsec_rmv() break elif server_type == "0": clear() editrmv_geneve_ipsec() break else: print("Invalid choice.") def edit_kharejgenudpsec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve UDP IPsec Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "2": genz2u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "3": genz3u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "4": genz4u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "5": genz5u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "0": clear() editir_genudpsec_rmv() break else: print("Invalid choice.") # gen native ipsec def edit_gennativesec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve V6 IPsec\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_genudpsec6_rmv() break elif server_type == "2": editir_genudpsec6_rmv() break elif server_type == "0": clear() editrmv_geneve_ipsec() break else: print("Invalid choice.") def editkh_genudpsec6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve V6 IPsec [5]Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() break elif server_type == "2": genz2u_uninstall_sec() break elif server_type == "3": genz3u_uninstall_sec() break elif server_type == "4": genz4u_uninstall_sec() break elif server_type == "5": genz5u_uninstall_sec() break elif server_type == "6": edit_irangenudpsec6_rmv() break elif server_type == "0": clear() edit_gennativesec_rmv() break else: print("Invalid choice.") def edit_irangenudpsec6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve V6 IPsec IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "2": genz2u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "3": genz3u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "4": genz4u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "5": genz5u_uninstall_sec() iran11_ipsec_genedit2() break elif server_type == "0": clear() editkh_genudpsec6_rmv() break else: print("Invalid choice.") def editir_genudpsec6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve V6 IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() break elif server_type == "2": genz2u_uninstall_sec() break elif server_type == "3": genz3u_uninstall_sec() break elif server_type == "4": genz4u_uninstall_sec() break elif server_type == "5": genz5u_uninstall_sec() break elif server_type == "6": edit_kharejgenudpsec6_rmv() break elif server_type == "0": clear() edit_gennativesec_rmv() break else: print("Invalid choice.") def edit_kharejgenudpsec6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve V6 IPsec Kharej\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "2": genz2u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "3": genz3u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "4": genz4u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "5": genz5u_uninstall_sec() kharej11_ipsec_genedit2() break elif server_type == "0": clear() editir_genudpsec6_rmv() break else: print("Invalid choice.") # geneve gre6 v4 def editrmv_geneve_gre6sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve Gre6 V4 IPsec\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve GRE6 V4 + IPsec\033[0m") print("2. \033[93mGeneve GRE6 V6 + IPsec\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": edit_gengre6secv4_rmv() break elif server_type == "2": edit_gengre6secv6_rmv() break elif server_type == "0": clear() editremove_geneve() break else: print("Invalid choice.") def edit_gengre6secv4_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V4 IPsec\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gengre6v4sec_rmv() break elif server_type == "2": editir_gengre6v4sec_rmv() break elif server_type == "0": clear() editrmv_geneve_gre6sec() break else: print("Invalid choice.") def editkh_gengre6v4sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V4 IPsec [5]Kharej\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": edit_irangengre6v4sec_rmv() break elif server_type == "0": clear() edit_gengre6secv4_rmv() break else: print("Invalid choice.") def edit_irangengre6v4sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V4 IPsec IRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() iranp4_ipsec_questione2() break elif server_type == "2": genz2_uninstall_sec() iranp4_ipsec_questione2() break elif server_type == "3": genz3_uninstall_sec() iranp4_ipsec_questione2() break elif server_type == "4": genz4_uninstall_sec() iranp4_ipsec_questione2() break elif server_type == "5": genz5_uninstall_sec() iranp4_ipsec_questione2() break elif server_type == "0": clear() editkh_gengre6v4sec_rmv() break else: print("Invalid choice.") def editir_gengre6v4sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V4 IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": edit_kharejgengre6v4sec_rmv() break elif server_type == "0": clear() editrmv_geneve_gre6sec() break else: print("Invalid choice.") def edit_kharejgengre6v4sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V4 IPsec Kharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() kharejp4_ipsec_questione2() break elif server_type == "2": genz2_uninstall_sec() kharejp4_ipsec_questione2() break elif server_type == "3": genz3_uninstall_sec() kharejp4_ipsec_questione2() break elif server_type == "4": genz4_uninstall_sec() kharejp4_ipsec_questione2() break elif server_type == "5": genz5_uninstall_sec() kharejp4_ipsec_questione2() break elif server_type == "0": clear() editir_gengre6v4sec_rmv() break else: print("Invalid choice.") # geneve gre6 v6 def edit_gengre6secv6_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V6 IPsec\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej | [1]IRAN\033[0m") print("2. \033[93m[1]Kharej | [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": editkh_gengre6v6sec_rmv() break elif server_type == "2": editir_gengre6v6sec_rmv() break elif server_type == "0": clear() editrmv_geneve_gre6sec() break else: print("Invalid choice.") def editkh_gengre6v6sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V6 IPsec [5]Kharej\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej[1]\033[0m") print("2. \033[92mKharej[2]\033[0m") print("3. \033[93mKharej[3]\033[0m") print("4. \033[92mKharej[4]\033[0m") print("5. \033[92mKharej[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": edit_irangengre6v6sec_rmv() break elif server_type == "0": clear() edit_gengre6secv6_rmv() break else: print("Invalid choice.") def edit_irangengre6v6sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V6 IPsec IRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN-Tunnel[1]\033[0m") print("2. \033[92mIRAN-Tunnel[2]\033[0m") print("3. \033[93mIRAN-Tunnel[3]\033[0m") print("4. \033[92mIRAN-Tunnel[4]\033[0m") print("5. \033[92mIRAN-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() iran_ipsecz_questione2() break elif server_type == "2": genz2_uninstall_sec() iran_ipsecz_questione2() break elif server_type == "3": genz3_uninstall_sec() iran_ipsecz_questione2() break elif server_type == "4": genz4_uninstall_sec() iran_ipsecz_questione2() break elif server_type == "5": genz5_uninstall_sec() iran_ipsecz_questione2() break elif server_type == "0": clear() editkh_gengre6v6sec_rmv() break else: print("Invalid choice.") def editir_gengre6v6sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V6 IPsec [5]IRAN\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN[1]\033[0m") print("2. \033[92mIRAN[2]\033[0m") print("3. \033[93mIRAN[3]\033[0m") print("4. \033[92mIRAN[4]\033[0m") print("5. \033[92mIRAN[5]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() break elif server_type == "2": genz2_uninstall_sec() break elif server_type == "3": genz3_uninstall_sec() break elif server_type == "4": genz4_uninstall_sec() break elif server_type == "5": genz5_uninstall_sec() break elif server_type == "6": edit_kharejgengre6v6sec_rmv() break elif server_type == "0": clear() editrmv_geneve_gre6sec() break else: print("Invalid choice.") def edit_kharejgengre6v6sec_rmv(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Geneve GRE6 V6 IPsec Kharej\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej-Tunnel[1]\033[0m") print("2. \033[92mKharej-Tunnel[2]\033[0m") print("3. \033[93mKharej-Tunnel[3]\033[0m") print("4. \033[92mKharej-Tunnel[4]\033[0m") print("5. \033[92mKharej-Tunnel[5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz1_uninstall_sec() kharej_ipsecz_questione2() break elif server_type == "2": genz2_uninstall_sec() kharej_ipsecz_questione2() break elif server_type == "3": genz3_uninstall_sec() kharej_ipsecz_questione2() break elif server_type == "4": genz4_uninstall_sec() kharej_ipsecz_questione2() break elif server_type == "5": genz5_uninstall_sec() kharej_ipsecz_questione2() break elif server_type == "0": clear() editir_gengre6v6sec_rmv() break else: print("Invalid choice.") def mtu2_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mEdit MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m6TO4\033[0m") print("2. \033[93mIP6IP6 \033[0m") print("3. \033[92mGRE6 \033[0m") print("4. \033[93mGRE6tap \033[0m") print("5. \033[92mGeneve \033[0m") print("6. \033[96manycast \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_mnu() break elif server_type == "2": ip6_mnu() break elif server_type == "3": gre6mtu_mnu() break elif server_type == "4": gre6tapt_mnu() break elif server_type == "5": geneve_multi_mtumnu() break elif server_type == "6": i6to4any2_mtu() break elif server_type == "0": clear() multiserver_mnu() break else: print("Invalid choice.") def geneve_multi_mtumnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve UDP \033[0m") print("2. \033[93mGeneve + Native\033[0m") print("3. \033[96mGeneve + IPv4 + GRE6\033[0m") print("4. \033[92mGeneve + Native + GRE6\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": simplegenm_mnu() break elif server_type == "2": simplegenm_mnu() break elif server_type == "3": ipv4genm_mnu() break elif server_type == "4": ipv6genm_mnu() break elif server_type == "0": clear() mtu2_menu() break else: print("Invalid choice.") def ipv6genm_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip6_mutlti_mtuk5() break elif server_type == "2": genip6_mutlti_mtuk1() break elif server_type == "0": clear() geneve_multi_mtumnu() break else: print("Invalid choice.") def genip6_mutlti_mtuk5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genn1_mutli_mtu() break elif server_type == "2": genn2_mutli_mtu() break elif server_type == "3": genn3_mutli_mtu() break elif server_type == "4": genn4_mutli_mtu() break elif server_type == "5": genn5_mutli_mtu() break elif server_type == "6": ip6_mtu3_qgen() break elif server_type == "0": clear() ipv6genm_mnu() break else: print("Invalid choice.") def ip6_mtu3_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genn1_mutli_mtu() break elif server_type == "2": genn2_mutli_mtu() break elif server_type == "3": genn3_mutli_mtu() break elif server_type == "4": genn4_mutli_mtu() break elif server_type == "5": genn5_mutli_mtu() break elif server_type == "6": ip6_m3_qgen() break elif server_type == "0": clear() genip6_mutlti_mtuk5() break else: print("Invalid choice.") def ip6_m3_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genn{}_mutli_mtu()".format(i) globals()[menu_name]() def genip6_mutlti_mtuk1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genn1_mutli_mtu() break elif server_type == "2": genn2_mutli_mtu() break elif server_type == "3": genn3_mutli_mtu() break elif server_type == "4": genn4_mutli_mtu() break elif server_type == "5": genn5_mutli_mtu() break elif server_type == "6": ip6_mtu4_qgen() break elif server_type == "0": clear() ipv6genm_mnu() break else: print("Invalid choice.") def ip6_mtu4_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genn1_mutli_mtu() break elif server_type == "2": genn2_mutli_mtu() break elif server_type == "3": genn3_mutli_mtu() break elif server_type == "4": genn4_mutli_mtu() break elif server_type == "5": genn5_mutli_mtu() break elif server_type == "6": ip6_m4_qgen() break elif server_type == "0": clear() genip6_mutlti_mtuk1() break else: print("Invalid choice.") def ip6_m4_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genn{}_mutli_mtu()".format(i) globals()[menu_name]() # gen simple & native prequisite def gen1_mutli_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" if os.path.exists("/etc/sys1.sh"): with open("/etc/sys1.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen1 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys1.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen2_mutli_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" if os.path.exists("/etc/sys2.sh"): with open("/etc/sys2.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen2 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys2.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen3_mutli_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" if os.path.exists("/etc/sys3.sh"): with open("/etc/sys3.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen3 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys3.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen4_mutli_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" if os.path.exists("/etc/sys4.sh"): with open("/etc/sys4.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen4 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys4.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen5_mutli_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" if os.path.exists("/etc/sys5.sh"): with open("/etc/sys5.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen5 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys5.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # native def simplegenm_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_mutlti_mtuk5() break elif server_type == "2": gen_mutlti_mtuk1() break elif server_type == "0": clear() geneve_multi_mtumnu() break else: print("Invalid choice.") def gen_mutlti_mtuk5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_mutli_mtu() break elif server_type == "2": gen2_mutli_mtu() break elif server_type == "3": gen3_mutli_mtu() break elif server_type == "4": gen4_mutli_mtu() break elif server_type == "5": gen5_mutli_mtu() break elif server_type == "6": mtu3_qgen() break elif server_type == "0": clear() simplegenm_mnu() break else: print("Invalid choice.") def mtu3_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_mutli_mtu() break elif server_type == "2": gen2_mutli_mtu() break elif server_type == "3": gen3_mutli_mtu() break elif server_type == "4": gen4_mutli_mtu() break elif server_type == "5": gen5_mutli_mtu() break elif server_type == "6": m3_qgen() break elif server_type == "0": clear() gen_mutlti_mtuk5() break else: print("Invalid choice.") def m3_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gen{}_mutli_mtu".format(i) globals()[menu_name]() def gen_mutlti_mtuk1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_mutli_mtu() break elif server_type == "2": gen2_mutli_mtu() break elif server_type == "3": gen3_mutli_mtu() break elif server_type == "4": gen4_mutli_mtu() break elif server_type == "5": gen5_mutli_mtu() break elif server_type == "6": mtu4_qgen() break elif server_type == "0": clear() simplegenm_mnu() break else: print("Invalid choice.") def mtu4_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_mutli_mtu() break elif server_type == "2": gen2_mutli_mtu() break elif server_type == "3": gen3_mutli_mtu() break elif server_type == "4": gen4_mutli_mtu() break elif server_type == "5": gen5_mutli_mtu() break elif server_type == "6": m4_qgen() break elif server_type == "0": clear() gen_mutlti_mtuk1() break else: print("Invalid choice.") def m4_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gen{}_mutli_mtu".format(i) globals()[menu_name]() # ip4 gre6 gen def ipv4genm_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[5]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip4_mutlti_mtuk5() break elif server_type == "2": genip4_mutlti_mtuk1() break elif server_type == "0": clear() geneve_multi_mtumnu() break else: print("Invalid choice.") def genip4_mutlti_mtuk5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip41_mutli_mtu() break elif server_type == "2": genip42_mutli_mtu() break elif server_type == "3": genip43_mutli_mtu() break elif server_type == "4": genip44_mutli_mtu() break elif server_type == "5": genip45_mutli_mtu() break elif server_type == "6": ip4_mtu3_qgen() break elif server_type == "0": clear() ipv4genm_mnu() break else: print("Invalid choice.") def ip4_mtu3_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip41_mutli_mtu() break elif server_type == "2": genip42_mutli_mtu() break elif server_type == "3": genip43_mutli_mtu() break elif server_type == "4": genip44_mutli_mtu() break elif server_type == "5": genip45_mutli_mtu() break elif server_type == "6": ip4_m3_qgen() break elif server_type == "0": clear() genip4_mutlti_mtuk5() break else: print("Invalid choice.") def ip4_m3_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genip4{}_mutli_mtu".format(i) globals()[menu_name]() def genip4_mutlti_mtuk1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip41_mutli_mtu() break elif server_type == "2": genip42_mutli_mtu() break elif server_type == "3": genip43_mutli_mtu() break elif server_type == "4": genip44_mutli_mtu() break elif server_type == "5": genip45_mutli_mtu() break elif server_type == "6": ip4_mtu4_qgen() break elif server_type == "0": clear() ipv4genm_mnu() break else: print("Invalid choice.") def ip4_mtu4_qgen(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genip41_mutli_mtu() break elif server_type == "2": genip42_mutli_mtu() break elif server_type == "3": genip43_mutli_mtu() break elif server_type == "4": genip44_mutli_mtu() break elif server_type == "5": genip45_mutli_mtu() break elif server_type == "6": ip4_m4_qgen() break elif server_type == "0": clear() genip4_mutlti_mtuk1() break else: print("Invalid choice.") def ip4_m4_qgen(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "genip4{}_mutli_mtu".format(i) globals()[menu_name]() ## gre6 gen ipv4 mtu prequisite def genip41_mutli_mtu(): gre6_kh1_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" if os.path.exists("/etc/sys1.sh"): with open("/etc/sys1.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen1 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys1.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genip42_mutli_mtu(): gre6_kh2_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" if os.path.exists("/etc/sys2.sh"): with open("/etc/sys2.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen2 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys2.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genip43_mutli_mtu(): gre6_kh3_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" if os.path.exists("/etc/sys3.sh"): with open("/etc/sys3.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen3 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys3.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genip44_mutli_mtu(): gre6_kh4_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" if os.path.exists("/etc/sys4.sh"): with open("/etc/sys4.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen4 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys4.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genip45_mutli_mtu(): gre6_kh5_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" if os.path.exists("/etc/sys5.sh"): with open("/etc/sys5.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen5 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys5.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genn1_mutli_mtu(): gre6_kh1tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen1 mtu {mtu_value}\n" if os.path.exists("/etc/sys1.sh"): with open("/etc/sys1.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen1 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys1.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genn2_mutli_mtu(): gre6_kh2tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen2 mtu {mtu_value}\n" if os.path.exists("/etc/sys2.sh"): with open("/etc/sys2.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen2 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys2.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genn3_mutli_mtu(): gre6_kh3tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen3 mtu {mtu_value}\n" if os.path.exists("/etc/sys3.sh"): with open("/etc/sys3.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen3 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys3.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genn4_mutli_mtu(): gre6_kh4tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen4 mtu {mtu_value}\n" if os.path.exists("/etc/sys4.sh"): with open("/etc/sys4.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen4 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys4.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def genn5_mutli_mtu(): gre6_kh5tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen5 mtu {mtu_value}\n" if os.path.exists("/etc/sys5.sh"): with open("/etc/sys5.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen5 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys5.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def private_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mPrivateIP Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("3. \033[92m[5]Kharej [1]IRAN + IPSEC\033[0m") print("4. \033[93m[1]Kharej [5]IRAN + IPSEC\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": khprivate_mnu() break elif server_type == "2": irprivate_mnu() break elif server_type == "3": khprivate_mnu2() break elif server_type == "4": irprivate_mnu() break elif server_type == "0": clear() mtu2_menu() break else: print("Invalid choice.") def khprivate_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[10]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[93mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[93mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("11. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh1_mtu() break elif server_type == "2": priv_kh2_mtu() break elif server_type == "3": priv_kh3_mtu() break elif server_type == "4": priv_kh4_mtu() break elif server_type == "5": priv_kh5_mtu() break elif server_type == "6": priv_kh6_mtu() break elif server_type == "7": priv_kh7_mtu() break elif server_type == "8": priv_kh8_mtu() break elif server_type == "9": priv_kh9_mtu() break elif server_type == "10": priv_kh10_mtu() break elif server_type == "11": mtu1_q() break elif server_type == "0": clear() private_mnu() break else: print("Invalid choice.") def mtu1_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[93mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[92mTunnel [6]\033[0m") print("7. \033[93mTunnel [7]\033[0m") print("8. \033[93mTunnel [8]\033[0m") print("9. \033[92mTunnel [9]\033[0m") print("10.\033[92mTunnel [10]\033[0m") print("11.\033[96mAll OF Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1_mtu() break elif server_type == "2": priv_ir2_mtu() break elif server_type == "3": priv_ir3_mtu() break elif server_type == "4": priv_ir4_mtu() break elif server_type == "5": priv_ir5_mtu() break elif server_type == "6": priv_ir6_mtu() break elif server_type == "7": priv_ir7_mtu() break elif server_type == "8": priv_ir8_mtu() break elif server_type == "9": priv_ir9_mtu() break elif server_type == "10": priv_ir10_mtu() break elif server_type == "11": mtu1_q1() break elif server_type == "0": clear() khprivate_mnu() break else: print("Invalid choice.") def khprivate_mnu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej IPSEC Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[93mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_kh1_mtu() break elif server_type == "2": priv_kh2_mtu() break elif server_type == "3": priv_kh3_mtu() break elif server_type == "4": priv_kh4_mtu() break elif server_type == "5": priv_kh5_mtu() break elif server_type == "6": mtu1_q22() break elif server_type == "0": clear() private_mnu() break else: print("Invalid choice.") def mtu1_q22(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN IPSEC MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[93mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6.\033[96mAll OF Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1_mtu() break elif server_type == "2": priv_ir2_mtu() break elif server_type == "3": priv_ir3_mtu() break elif server_type == "4": priv_ir4_mtu() break elif server_type == "5": priv_ir5_mtu() break elif server_type == "6": mtu1_q1() break elif server_type == "0": clear() khprivate_mnu() break else: print("Invalid choice.") ##later usage def mtu1_q1(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_ir{}_mtu".format(i) globals()[menu_name]() def irprivate_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[93mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1_mtu() break elif server_type == "2": priv_ir2_mtu() break elif server_type == "3": priv_ir3_mtu() break elif server_type == "4": priv_ir4_mtu() break elif server_type == "5": priv_ir5_mtu() break elif server_type == "6": mtu2_q() break elif server_type == "0": clear() private_mnu() break else: print("Invalid choice.") def mtu2_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[93mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll OF Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": priv_ir1_mtu() break elif server_type == "2": priv_ir2_mtu() break elif server_type == "3": priv_ir3_mtu() break elif server_type == "4": priv_ir4_mtu() break elif server_type == "5": priv_ir5_mtu() break elif server_type == "6": mtu1_q2() break elif server_type == "0": clear() irprivate_mnu() break else: print("Invalid choice.") # later usage def mtu1_q2(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "priv_kh{}_mtu".format(i) globals()[menu_name]() ## gre6 & gre6tap menu def gre6tapt_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6 Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNative GREtap [IPSEC too]\033[0m") print("2. \033[93mIPV4 GREtap [IPSEC too] \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": nativegretap_mnu() break elif server_type == "2": gre6t_mnu() break elif server_type == "0": clear() mtu2_menu() break else: print("Invalid choice.") # native def nativegretap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6tap Native [IPSEC too] Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("3. \033[92m[5]Kharej [1]IRAN + IPSEC\033[0m") print("4. \033[93m[1]Kharej [5]IRAN + IPSEC\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": khgre6tap_mnu() break elif server_type == "2": irgre6tap_mnu() break elif server_type == "3": khgre6tap_mnu() break elif server_type == "4": irgre6tap_mnu() break elif server_type == "0": clear() gre6tapt_mnu() break else: print("Invalid choice.") ## gre6 kharej menu def khgre6tap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[10]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[92mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("11. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1tap_mtu() break elif server_type == "2": gre6_kh2tap_mtu() break elif server_type == "3": gre6_kh3tap_mtu() break elif server_type == "4": gre6_kh4tap_mtu() break elif server_type == "5": gre6_kh5tap_mtu() break elif server_type == "6": gre6_kh6tap_mtu() break elif server_type == "7": gre6_kh7tap_mtu() break elif server_type == "8": gre6_kh8tap_mtu() break elif server_type == "9": gre6_kh9tap_mtu() break elif server_type == "10": gre6_kh10tap_mtu() break elif server_type == "11": mtu3_qtap() break elif server_type == "0": clear() nativegretap_mnu() break else: print("Invalid choice.") def mtu3_qtap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[92mTunnel [6]\033[0m") print("7. \033[92mTunnel [7]\033[0m") print("8. \033[93mTunnel [8]\033[0m") print("9. \033[92mTunnel [9]\033[0m") print("10. 033[92mTunnel [10]\033[0m") print("11. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1tap_mtu() break elif server_type == "2": gre6_ir2tap_mtu() break elif server_type == "3": gre6_ir3tap_mtu() break elif server_type == "4": gre6_ir4tap_mtu() break elif server_type == "5": gre6_ir5tap_mtu() break elif server_type == "6": gre6_ir6tap_mtu() break elif server_type == "7": gre6_ir7tap_mtu() break elif server_type == "8": gre6_ir8tap_mtu() break elif server_type == "9": gre6_ir9tap_mtu() break elif server_type == "10": gre6_ir10tap_mtu() break elif server_type == "11": m3_qtap() break elif server_type == "0": clear() khgre6tap_mnu() break else: print("Invalid choice.") def m3_qtap(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6_ir{}tap_mtu".format(i) globals()[menu_name]() def khgre6tap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej IPSEC Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1tap_mtu() break elif server_type == "2": gre6_kh2tap_mtu() break elif server_type == "3": gre6_kh3tap_mtu() break elif server_type == "4": gre6_kh4tap_mtu() break elif server_type == "5": gre6_kh5tap_mtu() break elif server_type == "6": mtu3_qtap22() break elif server_type == "0": clear() nativegretap_mnu() break else: print("Invalid choice.") def mtu3_qtap22(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN IPSEC Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1tap_mtu() break elif server_type == "2": gre6_ir2tap_mtu() break elif server_type == "3": gre6_ir3tap_mtu() break elif server_type == "4": gre6_ir4tap_mtu() break elif server_type == "5": gre6_ir5tap_mtu() break elif server_type == "6": m3_qtap() break elif server_type == "0": clear() khgre6tap_mnu() break else: print("Invalid choice.") def irgre6tap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1tap_mtu() break elif server_type == "2": gre6_ir2tap_mtu() break elif server_type == "3": gre6_ir3tap_mtu() break elif server_type == "4": gre6_ir4tap_mtu() break elif server_type == "5": gre6_ir5tap_mtu() break elif server_type == "6": mtu4_qtap() break elif server_type == "0": clear() nativegretap_mnu() break else: print("Invalid choice.") def mtu4_qtap(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1tap_mtu() break elif server_type == "2": gre6_kh2tap_mtu() break elif server_type == "3": gre6_kh3tap_mtu() break elif server_type == "4": gre6_kh4tap_mtu() break elif server_type == "5": gre6_kh5tap_mtu() break elif server_type == "6": m4_qtap() break elif server_type == "0": clear() irgre6tap_mnu() break else: print("Invalid choice.") def m4_qtap(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6_kh{}tap_mtu".format(i) globals()[menu_name]() ## def gre6t_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6tap V4 [IPSEC too] Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("3. \033[92m[5]Kharej [1]IRAN + IPSEC\033[0m") print("4. \033[93m[1]Kharej [5]IRAN + IPSEC\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": khgre6_mnu() break elif server_type == "2": irgre6_mnu() break elif server_type == "3": khgre6_mnu2() break elif server_type == "4": irgre6_mnu() break elif server_type == "0": clear() gre6tapt_mnu() break else: print("Invalid choice.") def gre6mtu_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6 Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [5]IRAN \033[0m") print("3. \033[92m[5]Kharej [1]IRAN + IPSEC\033[0m") print("4. \033[93m[1]Kharej [5]IRAN + IPSEC\033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": khgre6_mnu() break elif server_type == "2": irgre6_mnu() break elif server_type == "3": khgre6_mnu2() break elif server_type == "4": irgre6_mnu() break elif server_type == "0": clear() mtu2_menu() break else: print("Invalid choice.") ## gre6 kharej menu def khgre6_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[10]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[92mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("11. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1_mtu() break elif server_type == "2": gre6_kh2_mtu() break elif server_type == "3": gre6_kh3_mtu() break elif server_type == "4": gre6_kh4_mtu() break elif server_type == "5": gre6_kh5_mtu() break elif server_type == "6": gre6_kh6_mtu() break elif server_type == "7": gre6_kh7_mtu() break elif server_type == "8": gre6_kh8_mtu() break elif server_type == "9": gre6_kh9_mtu() break elif server_type == "10": gre6_kh10_mtu() break elif server_type == "11": mtu3_q() break elif server_type == "0": clear() gre6mtu_mnu() break else: print("Invalid choice.") def mtu3_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[92mTunnel [6]\033[0m") print("7. \033[92mTunnel [7]\033[0m") print("8. \033[93mTunnel [8]\033[0m") print("9. \033[92mTunnel [9]\033[0m") print("10.\033[92mTunnel [10]\033[0m") print("11.\033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1_mtu() break elif server_type == "2": gre6_ir2_mtu() break elif server_type == "3": gre6_ir3_mtu() break elif server_type == "4": gre6_ir4_mtu() break elif server_type == "5": gre6_ir5_mtu() break elif server_type == "6": gre6_ir6_mtu() break elif server_type == "7": gre6_ir7_mtu() break elif server_type == "8": gre6_ir8_mtu() break elif server_type == "9": gre6_ir9_mtu() break elif server_type == "10": gre6_ir10_mtu() break elif server_type == "11": m3_q() break elif server_type == "0": clear() khgre6_mnu() break else: print("Invalid choice.") def m3_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6_ir{}_mtu".format(i) globals()[menu_name]() def khgre6_mnu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]Kharej IPSEC Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1_mtu() break elif server_type == "2": gre6_kh2_mtu() break elif server_type == "3": gre6_kh3_mtu() break elif server_type == "4": gre6_kh4_mtu() break elif server_type == "5": gre6_kh5_mtu() break elif server_type == "6": mtu3_q22() break elif server_type == "0": clear() gre6mtu_mnu() break else: print("Invalid choice.") def mtu3_q22(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6.\033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1_mtu() break elif server_type == "2": gre6_ir2_mtu() break elif server_type == "3": gre6_ir3_mtu() break elif server_type == "4": gre6_ir4_mtu() break elif server_type == "5": gre6_ir5_mtu() break elif server_type == "6": m3_q() break elif server_type == "0": clear() khgre6_mnu() break else: print("Invalid choice.") def irgre6_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6. \033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_ir1_mtu() break elif server_type == "2": gre6_ir2_mtu() break elif server_type == "3": gre6_ir3_mtu() break elif server_type == "4": gre6_ir4_mtu() break elif server_type == "5": gre6_ir5_mtu() break elif server_type == "6": mtu4_q() break elif server_type == "0": clear() gre6mtu_mnu() break else: print("Invalid choice.") def mtu4_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_kh1_mtu() break elif server_type == "2": gre6_kh2_mtu() break elif server_type == "3": gre6_kh3_mtu() break elif server_type == "4": gre6_kh4_mtu() break elif server_type == "5": gre6_kh5_mtu() break elif server_type == "6": m4_q() break elif server_type == "0": clear() irgre6_mnu() break else: print("Invalid choice.") def m4_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "gre6_kh{}_mtu".format(i) globals()[menu_name]() ## ipip6 menu def ip6_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIP6IP6 Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m[10]Kharej [1]IRAN\033[0m") print("2. \033[93m[1]Kharej [10]IRAN \033[0m") print("3. \033[92m[5]Kharej [1]IRAN + IPSEC\033[0m") print("4. \033[93m[1]Kharej [5]IRAN + IPSEC \033[0m") print("0. \033[94mback to the MTU menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": khip6_mnu() break elif server_type == "2": irip6_mnu() break elif server_type == "3": khip6_mnu2() break elif server_type == "4": irip6_mnu2() break elif server_type == "0": clear() mtu2_menu() break else: print("Invalid choice.") def khip6_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[10]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("6. \033[92mKharej [6]\033[0m") print("7. \033[92mKharej [7]\033[0m") print("8. \033[93mKharej [8]\033[0m") print("9. \033[92mKharej [9]\033[0m") print("10.\033[92mKharej [10]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("11.\033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_kh1_mtu() break elif server_type == "2": ipip_kh2_mtu() break elif server_type == "3": ipip_kh3_mtu() break elif server_type == "4": ipip_kh4_mtu() break elif server_type == "5": ipip_kh5_mtu() break elif server_type == "6": ipip_kh6_mtu() break elif server_type == "7": ipip_kh7_mtu() break elif server_type == "8": ipip_kh8_mtu() break elif server_type == "9": ipip_kh9_mtu() break elif server_type == "10": ipip_kh10_mtu() break elif server_type == "11": mtu5_q() break elif server_type == "0": clear() ip6_mnu() break else: print("Invalid choice.") def mtu5_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[92mTunnel [6]\033[0m") print("7. \033[92mTunnel [7]\033[0m") print("8. \033[93mTunnel [8]\033[0m") print("9. \033[92mTunnel [9]\033[0m") print("10.\033[92mTunnel [10]\033[0m") print("11.\033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_ir1_mtu() break elif server_type == "2": ipip_ir2_mtu() break elif server_type == "3": ipip_ir3_mtu() break elif server_type == "4": ipip_ir4_mtu() break elif server_type == "5": ipip_ir5_mtu() break elif server_type == "6": ipip_ir6_mtu() break elif server_type == "7": ipip_ir7_mtu() break elif server_type == "8": ipip_ir8_mtu() break elif server_type == "9": ipip_ir9_mtu() break elif server_type == "10": ipip_ir10_mtu() break elif server_type == "11": m5_q() break elif server_type == "0": clear() khip6_mnu() break else: print("Invalid choice.") def m5_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mKharej Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "ipip_ir{}_mtu".format(i) globals()[menu_name]() # ipip mtu sec def khip6_mnu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[10]Kharej Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej [1]\033[0m") print("2. \033[92mKharej [2]\033[0m") print("3. \033[93mKharej [3]\033[0m") print("4. \033[92mKharej [4]\033[0m") print("5. \033[92mKharej [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6.\033[93mIRAN \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_kh1_mtu() break elif server_type == "2": ipip_kh2_mtu() break elif server_type == "3": ipip_kh3_mtu() break elif server_type == "4": ipip_kh4_mtu() break elif server_type == "5": ipip_kh5_mtu() break elif server_type == "6": mtu5_q22() break elif server_type == "0": clear() ip6_mnu() break else: print("Invalid choice.") def mtu5_q22(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6.\033[96mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_ir1_mtu() break elif server_type == "2": ipip_ir2_mtu() break elif server_type == "3": ipip_ir3_mtu() break elif server_type == "4": ipip_ir4_mtu() break elif server_type == "5": ipip_ir5_mtu() break elif server_type == "6": m5_q() break elif server_type == "0": clear() khip6_mnu2() break else: print("Invalid choice.") def irip6_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("6. \033[92mIRAN [6]\033[0m") print("7. \033[92mIRAN [7]\033[0m") print("8. \033[93mIRAN [8]\033[0m") print("9. \033[92mIRAN [9]\033[0m") print("10.\033[92mIRAN [10]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("11.\033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_ir1_mtu() break elif server_type == "2": ipip_ir2_mtu() break elif server_type == "3": ipip_ir3_mtu() break elif server_type == "4": ipip_ir4_mtu() break elif server_type == "5": ipip_ir5_mtu() break elif server_type == "6": ipip_ir6_mtu() break elif server_type == "7": ipip_ir7_mtu() break elif server_type == "8": ipip_ir8_mtu() break elif server_type == "9": ipip_ir9_mtu() break elif server_type == "10": ipip_ir10_mtu() break elif server_type == "11": mtu6_q() break elif server_type == "0": clear() ip6_mnu() break else: print("Invalid choice.") def mtu6_q(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6. \033[92mTunnel [6]\033[0m") print("7. \033[92mTunnel [7]\033[0m") print("8. \033[93mTunnel [8]\033[0m") print("9. \033[92mTunnel [9]\033[0m") print("10.\033[92mTunnel [10]\033[0m") print("11.\033[92mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_kh1_mtu() break elif server_type == "2": ipip_kh2_mtu() break elif server_type == "3": ipip_kh3_mtu() break elif server_type == "4": ipip_kh4_mtu() break elif server_type == "5": ipip_kh5_mtu() break elif server_type == "6": ipip_kh6_mtu() break elif server_type == "7": ipip_kh7_mtu() break elif server_type == "8": ipip_kh8_mtu() break elif server_type == "9": ipip_kh9_mtu() break elif server_type == "10": ipip_kh10_mtu() break elif server_type == "11": m6_q() break elif server_type == "0": clear() irip6_mnu() break else: print("Invalid choice.") def m6_q(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mQuestion time !\033[0m") print("\033[93m───────────────────────────────────────\033[0m") num_servers = int( input("\033[93mHow many \033[92mIRAN Servers\033[93m do you have?\033[0m ") ) for i in range(1, num_servers + 1): menu_name = "ipip_kh{}_mtu".format(i) globals()[menu_name]() # ipip mtu sec def irip6_mnu2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m[5]IRAN Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIRAN [1]\033[0m") print("2. \033[92mIRAN [2]\033[0m") print("3. \033[93mIRAN [3]\033[0m") print("4. \033[92mIRAN [4]\033[0m") print("5. \033[92mIRAN [5]\033[0m") print("\033[93m──────────────────────────────────────\033[0m") print("6.\033[93mKharej \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_ir1_mtu() break elif server_type == "2": ipip_ir2_mtu() break elif server_type == "3": ipip_ir3_mtu() break elif server_type == "4": ipip_ir4_mtu() break elif server_type == "5": ipip_ir5_mtu() break elif server_type == "6": mtu6_q22() break elif server_type == "0": clear() ip6_mnu() break else: print("Invalid choice.") def mtu6_q22(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKHAREJ Edit Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mTunnel [1]\033[0m") print("2. \033[92mTunnel [2]\033[0m") print("3. \033[93mTunnel [3]\033[0m") print("4. \033[92mTunnel [4]\033[0m") print("5. \033[92mTunnel [5]\033[0m") print("6.\033[92mAll Of Them\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip_kh1_mtu() break elif server_type == "2": ipip_kh2_mtu() break elif server_type == "3": ipip_kh3_mtu() break elif server_type == "4": ipip_kh4_mtu() break elif server_type == "5": ipip_kh5_mtu() break elif server_type == "6": m6_q() break elif server_type == "0": clear() irip6_mnu2() break else: print("Invalid choice.") def ipip_kh1_mtu(): priv_kh1_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip1 mtu {mtu_value}\n" if os.path.exists("/etc/ipip1.sh"): with open("/etc/ipip1.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip1 mtu" not in line ] with open("/etc/ipip1.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip1.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh2_mtu(): priv_kh2_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip2 mtu {mtu_value}\n" if os.path.exists("/etc/ipip2.sh"): with open("/etc/ipip2.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip2 mtu" not in line ] with open("/etc/ipip2.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip2.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh3_mtu(): priv_kh3_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip3 mtu {mtu_value}\n" if os.path.exists("/etc/ipip3.sh"): with open("/etc/ipip3.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip3 mtu" not in line ] with open("/etc/ipip3.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip3.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh4_mtu(): priv_kh4_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip4 mtu {mtu_value}\n" if os.path.exists("/etc/ipip4.sh"): with open("/etc/ipip4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip4 mtu" not in line ] with open("/etc/ipip4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip4.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh5_mtu(): priv_kh5_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip5 mtu {mtu_value}\n" if os.path.exists("/etc/ipip5.sh"): with open("/etc/ipip5.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip5 mtu" not in line ] with open("/etc/ipip5.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip5.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh6_mtu(): priv_kh6_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip6 mtu {mtu_value}\n" if os.path.exists("/etc/ipip6.sh"): with open("/etc/ipip6.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip6 mtu" not in line ] with open("/etc/ipip6.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip6.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh7_mtu(): priv_kh7_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip7 mtu {mtu_value}\n" if os.path.exists("/etc/ipip7.sh"): with open("/etc/ipip7.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip7 mtu" not in line ] with open("/etc/ipip7.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip7.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh8_mtu(): priv_kh8_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip8 mtu {mtu_value}\n" if os.path.exists("/etc/ipip8.sh"): with open("/etc/ipip8.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip8 mtu" not in line ] with open("/etc/ipip8.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip8.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh9_mtu(): priv_kh9_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip9 mtu {mtu_value}\n" if os.path.exists("/etc/ipip9.sh"): with open("/etc/ipip9.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip9 mtu" not in line ] with open("/etc/ipip9.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip9.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_kh10_mtu(): priv_kh10_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip10 mtu {mtu_value}\n" if os.path.exists("/etc/ipip10.sh"): with open("/etc/ipip10.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip10 mtu" not in line ] with open("/etc/ipip10.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip10.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir1_mtu(): priv_ir1_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip1 mtu {mtu_value}\n" if os.path.exists("/etc/ipip1.sh"): with open("/etc/ipip1.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip1 mtu" not in line ] with open("/etc/ipip1.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip1.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir2_mtu(): priv_ir2_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip2 mtu {mtu_value}\n" if os.path.exists("/etc/ipip2.sh"): with open("/etc/ipip2.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip2 mtu" not in line ] with open("/etc/ipip2.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip2.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir3_mtu(): priv_ir3_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip3 mtu {mtu_value}\n" if os.path.exists("/etc/ipip3.sh"): with open("/etc/ipip3.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip3 mtu" not in line ] with open("/etc/ipip3.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip3.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir4_mtu(): priv_ir4_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip4 mtu {mtu_value}\n" if os.path.exists("/etc/ipip4.sh"): with open("/etc/ipip4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip4 mtu" not in line ] with open("/etc/ipip4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip4.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir5_mtu(): priv_ir5_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip5 mtu {mtu_value}\n" if os.path.exists("/etc/ipip5.sh"): with open("/etc/ipip5.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip5 mtu" not in line ] with open("/etc/ipip5.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip5.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir6_mtu(): priv_ir6_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip6 mtu {mtu_value}\n" if os.path.exists("/etc/ipip6.sh"): with open("/etc/ipip6.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip6 mtu" not in line ] with open("/etc/ipip6.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip6.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir7_mtu(): priv_ir7_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip7 mtu {mtu_value}\n" if os.path.exists("/etc/ipip7.sh"): with open("/etc/ipip7.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip7 mtu" not in line ] with open("/etc/ipip7.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip7.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir8_mtu(): priv_ir8_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip8 mtu {mtu_value}\n" if os.path.exists("/etc/ipip8.sh"): with open("/etc/ipip8.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip8 mtu" not in line ] with open("/etc/ipip8.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip8.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir9_mtu(): priv_ir9_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip9 mtu {mtu_value}\n" if os.path.exists("/etc/ipip9.sh"): with open("/etc/ipip9.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip9 mtu" not in line ] with open("/etc/ipip9.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip9.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_ir10_mtu(): priv_ir10_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip10 mtu {mtu_value}\n" if os.path.exists("/etc/ipip10.sh"): with open("/etc/ipip10.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumip10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumip10 mtu" not in line ] with open("/etc/ipip10.sh", "w") as file: file.writelines(sh_contents) with open("/etc/ipip10.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" if os.path.exists("/etc/private1.sh"): with open("/etc/private1.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi1 mtu" not in line ] with open("/etc/private1.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private1.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" if os.path.exists("/etc/private2.sh"): with open("/etc/private2.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi2 mtu" not in line ] with open("/etc/private2.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private2.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" if os.path.exists("/etc/private3.sh"): with open("/etc/private3.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi3 mtu" not in line ] with open("/etc/private3.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private3.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" if os.path.exists("/etc/private4.sh"): with open("/etc/private4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi4 mtu" not in line ] with open("/etc/private4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private4.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" if os.path.exists("/etc/private5.sh"): with open("/etc/private5.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi5 mtu" not in line ] with open("/etc/private5.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private5.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" if os.path.exists("/etc/private6.sh"): with open("/etc/private6.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi6 mtu" not in line ] with open("/etc/private6.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private6.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" if os.path.exists("/etc/private7.sh"): with open("/etc/private7.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi7 mtu" not in line ] with open("/etc/private7.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private7.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" if os.path.exists("/etc/private8.sh"): with open("/etc/private8.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi8 mtu" not in line ] with open("/etc/private8.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private8.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" if os.path.exists("/etc/private9.sh"): with open("/etc/private9.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi9 mtu" not in line ] with open("/etc/private9.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private9.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" if os.path.exists("/etc/private10.sh"): with open("/etc/private10.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi10 mtu" not in line ] with open("/etc/private10.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private10.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # iran mtu private def priv_ir1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi1 mtu {mtu_value}\n" if os.path.exists("/etc/private1.sh"): with open("/etc/private1.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi1 mtu" not in line ] with open("/etc/private1.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private1.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi2 mtu {mtu_value}\n" if os.path.exists("/etc/private2.sh"): with open("/etc/private2.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi2 mtu" not in line ] with open("/etc/private2.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private2.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi3 mtu {mtu_value}\n" if os.path.exists("/etc/private3.sh"): with open("/etc/private3.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi3 mtu" not in line ] with open("/etc/private3.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private3.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi4 mtu {mtu_value}\n" if os.path.exists("/etc/private4.sh"): with open("/etc/private4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi4 mtu" not in line ] with open("/etc/private4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private4.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi5 mtu {mtu_value}\n" if os.path.exists("/etc/private5.sh"): with open("/etc/private5.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi5 mtu" not in line ] with open("/etc/private5.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private5.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" if os.path.exists("/etc/private6.sh"): with open("/etc/private6.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi6 mtu" not in line ] with open("/etc/private6.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private6.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi7 mtu {mtu_value}\n" if os.path.exists("/etc/private7.sh"): with open("/etc/private7.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi7 mtu" not in line ] with open("/etc/private7.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private7.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi8 mtu {mtu_value}\n" if os.path.exists("/etc/private8.sh"): with open("/etc/private8.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi8 mtu" not in line ] with open("/etc/private8.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private8.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi9 mtu {mtu_value}\n" if os.path.exists("/etc/private9.sh"): with open("/etc/private9.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi9 mtu" not in line ] with open("/etc/private9.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private9.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi10 mtu {mtu_value}\n" if os.path.exists("/etc/private10.sh"): with open("/etc/private10.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi10 mtu" not in line ] with open("/etc/private10.sh", "w") as file: file.writelines(sh_contents) with open("/etc/private10.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh1s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates11.sh"): with open("/etc/privates11.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config1 mtu" not in line ] with open("/etc/privates11.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates11.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh2s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates12.sh"): with open("/etc/privates12.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config2 mtu" not in line ] with open("/etc/privates12.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates12.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh3s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates13.sh"): with open("/etc/privates13.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config3 mtu" not in line ] with open("/etc/privates13.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates13.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh4s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates14.sh"): with open("/etc/privates14.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config4 mtu" not in line ] with open("/etc/privates14.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates14.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh5s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates15.sh"): with open("/etc/privates15.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config5 mtu" not in line ] with open("/etc/privates15.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates15.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh6s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates16.sh"): with open("/etc/privates16.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config6 mtu" not in line ] with open("/etc/privates16.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates16.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh7s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates17.sh"): with open("/etc/privates17.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config7 mtu" not in line ] with open("/etc/privates17.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates17.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh8s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates18.sh"): with open("/etc/privates18.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config8 mtu" not in line ] with open("/etc/privates18.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates18.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh9s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates19.sh"): with open("/etc/privates19.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config9 mtu" not in line ] with open("/etc/privates19.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates19.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_kh10s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates110.sh"): with open("/etc/privates110.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config10 mtu" not in line ] with open("/etc/privates110.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates110.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # iran mtu private def priv_ir1s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 1\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config1 mtu {mtu_value}\n" if os.path.exists("/etc/privates11.sh"): with open("/etc/privates11.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config1 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config1 mtu" not in line ] with open("/etc/privates11.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates11.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir2s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 2\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config2 mtu {mtu_value}\n" if os.path.exists("/etc/privates12.sh"): with open("/etc/privates12.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config2 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config2 mtu" not in line ] with open("/etc/privates12.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates12.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir3s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 3\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config3 mtu {mtu_value}\n" if os.path.exists("/etc/privates13.sh"): with open("/etc/privates13.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config3 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config3 mtu" not in line ] with open("/etc/privates13.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates13.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir4s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 4\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config4 mtu {mtu_value}\n" if os.path.exists("/etc/privates14.sh"): with open("/etc/privates14.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config4 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config4 mtu" not in line ] with open("/etc/privates14.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates14.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir5s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 5\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config5 mtu {mtu_value}\n" if os.path.exists("/etc/privates15.sh"): with open("/etc/privates15.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config5 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config5 mtu" not in line ] with open("/etc/privates15.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates15.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir6s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 6\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config6 mtu {mtu_value}\n" if os.path.exists("/etc/privates16.sh"): with open("/etc/privates16.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config6 mtu" not in line ] with open("/etc/privates16.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates16.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir7s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 7\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config7 mtu {mtu_value}\n" if os.path.exists("/etc/privates17.sh"): with open("/etc/privates17.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config7 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config7 mtu" not in line ] with open("/etc/privates17.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates17.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir8s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 8\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config8 mtu {mtu_value}\n" if os.path.exists("/etc/privates18.sh"): with open("/etc/privates18.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config8 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config8 mtu" not in line ] with open("/etc/privates18.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates18.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir9s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 9\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config9 mtu {mtu_value}\n" if os.path.exists("/etc/privates19.sh"): with open("/etc/privates19.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config9 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config9 mtu" not in line ] with open("/etc/privates19.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates19.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def priv_ir10s1_mtu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server 10\033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev iran1config10 mtu {mtu_value}\n" if os.path.exists("/etc/privates110.sh"): with open("/etc/privates110.sh", "r") as file: sh_contents = file.readlines() if any("link set dev iran1config10 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev iran1config10 mtu" not in line ] with open("/etc/privates110.sh", "w") as file: file.writelines(sh_contents) with open("/etc/privates110.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") ## gre6 mtu Kharej def gre6_kh1_mtu(): priv_kh1_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" if os.path.exists("/etc/gre61.sh"): with open("/etc/gre61.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig61 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig61 mtu" not in line ] with open("/etc/gre61.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre61.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh2_mtu(): priv_kh2_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" if os.path.exists("/etc/gre62.sh"): with open("/etc/gre62.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig62 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig62 mtu" not in line ] with open("/etc/gre62.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre62.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh3_mtu(): priv_kh3_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" if os.path.exists("/etc/gre63.sh"): with open("/etc/gre63.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig63 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig63 mtu" not in line ] with open("/etc/gre63.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre63.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh4_mtu(): priv_kh4_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" if os.path.exists("/etc/gre64.sh"): with open("/etc/gre64.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig64 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig64 mtu" not in line ] with open("/etc/gre64.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre64.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh5_mtu(): priv_kh5_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" if os.path.exists("/etc/gre65.sh"): with open("/etc/gre65.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig65 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig65 mtu" not in line ] with open("/etc/gre65.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre65.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh6_mtu(): priv_kh6_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" if os.path.exists("/etc/gre66.sh"): with open("/etc/gre66.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig66 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig66 mtu" not in line ] with open("/etc/gre66.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre66.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh7_mtu(): priv_kh7_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" if os.path.exists("/etc/gre67.sh"): with open("/etc/gre67.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig67 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig67 mtu" not in line ] with open("/etc/gre67.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre67.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh8_mtu(): priv_kh8_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" if os.path.exists("/etc/gre68.sh"): with open("/etc/gre68.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig68 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig68 mtu" not in line ] with open("/etc/gre68.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre68.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh9_mtu(): priv_kh9_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" if os.path.exists("/etc/gre69.sh"): with open("/etc/gre69.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig69 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig69 mtu" not in line ] with open("/etc/gre69.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre69.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh10_mtu(): priv_kh10_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" if os.path.exists("/etc/gre610.sh"): with open("/etc/gre610.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig610 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig610 mtu" not in line ] with open("/etc/gre610.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre610.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") ##gre6 mtu iran def gre6_ir1_mtu(): priv_ir1_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" if os.path.exists("/etc/gre61.sh"): with open("/etc/gre61.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig61 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig61 mtu" not in line ] with open("/etc/gre61.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre61.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir2_mtu(): priv_ir2_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" if os.path.exists("/etc/gre62.sh"): with open("/etc/gre62.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig62 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig62 mtu" not in line ] with open("/etc/gre62.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre62.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir3_mtu(): priv_ir3_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" if os.path.exists("/etc/gre63.sh"): with open("/etc/gre63.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig63 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig63 mtu" not in line ] with open("/etc/gre63.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre63.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir4_mtu(): priv_ir4_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" if os.path.exists("/etc/gre64.sh"): with open("/etc/gre64.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig64 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig64 mtu" not in line ] with open("/etc/gre64.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre64.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir5_mtu(): priv_ir5_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" if os.path.exists("/etc/gre65.sh"): with open("/etc/gre65.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig65 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig65 mtu" not in line ] with open("/etc/gre65.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre65.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir6_mtu(): priv_ir6_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" if os.path.exists("/etc/gre66.sh"): with open("/etc/gre66.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig66 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig66 mtu" not in line ] with open("/etc/gre66.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre66.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir7_mtu(): priv_ir7_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" if os.path.exists("/etc/gre67.sh"): with open("/etc/gre67.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig67 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig67 mtu" not in line ] with open("/etc/gre67.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre67.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir8_mtu(): priv_ir8_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" if os.path.exists("/etc/gre68.sh"): with open("/etc/gre68.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig68 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig68 mtu" not in line ] with open("/etc/gre68.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre68.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir9_mtu(): priv_ir9_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" if os.path.exists("/etc/gre69.sh"): with open("/etc/gre69.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig69 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig69 mtu" not in line ] with open("/etc/gre69.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre69.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir10_mtu(): priv_ir10_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" if os.path.exists("/etc/gre610.sh"): with open("/etc/gre610.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig610 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig610 mtu" not in line ] with open("/etc/gre610.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre610.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") # gretapnative def gre6_kh1tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" if os.path.exists("/etc/gre61.sh"): with open("/etc/gre61.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig61 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig61 mtu" not in line ] with open("/etc/gre61.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre61.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh2tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" if os.path.exists("/etc/gre62.sh"): with open("/etc/gre62.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig62 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig62 mtu" not in line ] with open("/etc/gre62.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre62.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh3tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" if os.path.exists("/etc/gre63.sh"): with open("/etc/gre63.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig63 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig63 mtu" not in line ] with open("/etc/gre63.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre63.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh4tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" if os.path.exists("/etc/gre64.sh"): with open("/etc/gre64.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig64 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig64 mtu" not in line ] with open("/etc/gre64.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre64.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh5tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" if os.path.exists("/etc/gre65.sh"): with open("/etc/gre65.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig65 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig65 mtu" not in line ] with open("/etc/gre65.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre65.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh6tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" if os.path.exists("/etc/gre66.sh"): with open("/etc/gre66.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig66 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig66 mtu" not in line ] with open("/etc/gre66.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre66.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh7tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" if os.path.exists("/etc/gre67.sh"): with open("/etc/gre67.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig67 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig67 mtu" not in line ] with open("/etc/gre67.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre67.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh8tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" if os.path.exists("/etc/gre68.sh"): with open("/etc/gre68.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig68 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig68 mtu" not in line ] with open("/etc/gre68.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre68.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh9tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" if os.path.exists("/etc/gre69.sh"): with open("/etc/gre69.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig69 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig69 mtu" not in line ] with open("/etc/gre69.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre69.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_kh10tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" if os.path.exists("/etc/gre610.sh"): with open("/etc/gre610.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig610 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig610 mtu" not in line ] with open("/etc/gre610.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre610.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") ##gre6 mtu iran def gre6_ir1tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig61 mtu {mtu_value}\n" if os.path.exists("/etc/gre61.sh"): with open("/etc/gre61.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig61 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig61 mtu" not in line ] with open("/etc/gre61.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre61.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir2tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig62 mtu {mtu_value}\n" if os.path.exists("/etc/gre62.sh"): with open("/etc/gre62.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig62 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig62 mtu" not in line ] with open("/etc/gre62.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre62.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir3tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig63 mtu {mtu_value}\n" if os.path.exists("/etc/gre63.sh"): with open("/etc/gre63.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig63 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig63 mtu" not in line ] with open("/etc/gre63.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre63.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir4tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig64 mtu {mtu_value}\n" if os.path.exists("/etc/gre64.sh"): with open("/etc/gre64.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig64 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig64 mtu" not in line ] with open("/etc/gre64.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre64.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir5tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig65 mtu {mtu_value}\n" if os.path.exists("/etc/gre65.sh"): with open("/etc/gre65.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig65 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig65 mtu" not in line ] with open("/etc/gre65.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre65.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir6tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig66 mtu {mtu_value}\n" if os.path.exists("/etc/gre66.sh"): with open("/etc/gre66.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig66 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig66 mtu" not in line ] with open("/etc/gre66.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre66.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir7tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig67 mtu {mtu_value}\n" if os.path.exists("/etc/gre67.sh"): with open("/etc/gre67.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig67 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig67 mtu" not in line ] with open("/etc/gre67.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre67.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir8tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig68 mtu {mtu_value}\n" if os.path.exists("/etc/gre68.sh"): with open("/etc/gre68.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig68 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig68 mtu" not in line ] with open("/etc/gre68.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre68.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir9tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig69 mtu {mtu_value}\n" if os.path.exists("/etc/gre69.sh"): with open("/etc/gre69.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig69 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig69 mtu" not in line ] with open("/etc/gre69.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre69.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_ir10tap_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig610 mtu {mtu_value}\n" if os.path.exists("/etc/gre610.sh"): with open("/etc/gre610.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumig610 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumig610 mtu" not in line ] with open("/etc/gre610.sh", "w") as file: file.writelines(sh_contents) with open("/etc/gre610.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") ## def i6to4any2_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96m6to4 anycast \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumi6 mtu {mtu_value}\n" if os.path.exists("/etc/6to4.sh"): with open("/etc/6to4.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumi6 mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumi6 mtu" not in line ] with open("/etc/6to4.sh", "w") as file: file.writelines(sh_contents) with open("/etc/6to4.sh", "a") as file: file.write(mtu_command) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") ## original mtu def mtu_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mEdit MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mPrivate IP\033[0m") print("2. \033[93mIP6IP6 \033[0m") print("3. \033[96mGRE \033[0m") print("4. \033[92mGRE6 \033[0m") print("5. \033[92mGRE6tap \033[0m") print("6. \033[93m6to4 \033[0m") print("7. \033[96m6to4 anycast \033[0m") print("8. \033[92mGeneve \033[0m") print("9. \033[93mErspan \033[0m") print("10. \033[92mVxlan [IPsec too] \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_mtu() break elif server_type == "2": ipip_mtu() break elif server_type == "3": gre_mtu() break elif server_type == "4": gre6_mtu() break elif server_type == "5": gre6tap_mtu() break elif server_type == "6": i6to4_mtu() break elif server_type == "7": i6to4any_mtu() break elif server_type == "8": gen_mtu() break elif server_type == "9": erspan_mtu() break elif server_type == "10": vxlan_mtu() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def erspan_mtu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mErspan MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan\033[0m") print("2. \033[97mErspan + Native\033[0m") print("3. \033[93mGRE6 + IPV4 Erspan \033[0m") print("4. \033[96mGRE6 + Native Erspan \033[0m") print("5. \033[93mGRE6tap + IPV4 Erspan \033[0m") print("6. \033[96mGRE6tap + Native Erspan \033[0m") print("7. \033[92mIPsec Tunnels \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn1_mtu() break elif server_type == "2": spn1_mtu() break elif server_type == "3": spn3_mtu() break elif server_type == "4": spn4_mtu() break elif server_type == "5": spn5_mtu() break elif server_type == "6": spn6_mtu() break elif server_type == "7": spn7_mtu() break elif server_type == "0": clear() mtu_menu() break else: print("Invalid choice.") def spn7_mtu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mErspan + IPsec MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + IPsec\033[0m") print("2. \033[97mErspan + GRE6 IPV4\033[0m") print("3. \033[93mErspan + GRE6 Native \033[0m") print("4. \033[96mErspan + GRE6tap IPV4 \033[0m") print("5. \033[92mErspan + GRE6tap Native \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": spn1_mtu() break elif server_type == "2": spn3_mtu() break elif server_type == "3": spn4_mtu() break elif server_type == "4": spn5_mtu() break elif server_type == "5": spn6_mtu() break elif server_type == "0": clear() erspan_mtu() break else: print("Invalid choice.") def gre6tap21_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6tap \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" if os.path.exists("/etc/gre6.sh"): with open("/etc/gre6.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumig6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/gre6.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6tap_mtu(): private_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6tap \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" if os.path.exists("/etc/gre6.sh"): with open("/etc/gre6.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumig6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/gre6.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def spn1_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mErspan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" if os.path.exists("/etc/spn.sh"): with open("/etc/spn.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumiespn mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/spn.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def spn3_mtu(): private_mtu() gre621_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mErspan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" if os.path.exists("/etc/spn.sh"): with open("/etc/spn.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumiespn mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/spn.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def spn4_mtu(): gre621_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mErspan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" if os.path.exists("/etc/spn.sh"): with open("/etc/spn.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumiespn mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/spn.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def spn5_mtu(): gre6tap_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mErspan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" if os.path.exists("/etc/spn.sh"): with open("/etc/spn.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumiespn mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/spn.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def spn6_mtu(): private_mtu() gre6tap21_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mErspan \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" if os.path.exists("/etc/spn.sh"): with open("/etc/spn.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumiespn mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/spn.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen_mtu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGENEVE MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGENEVE\033[0m") print("2. \033[97mGENEVE + Native\033[0m") print("3. \033[93mGRE6 + IPV4 GENEVE \033[0m") print("4. \033[96mGRE6 + Native GENEVE \033[0m") print("5. \033[92mGENEVE + IP6tnl + GRE6 \033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_mtu() break elif server_type == "2": gen1_mtu() break elif server_type == "3": gen4_mtu() break elif server_type == "4": gen2_mtu() break elif server_type == "5": gen3_mtu() break elif server_type == "0": clear() main_menu() break else: print("Invalid choice.") def gen4_mtu(): private_mtu() gre621_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" if os.path.exists("/etc/sys.sh"): with open("/etc/sys.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen1_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" if os.path.exists("/etc/sys.sh"): with open("/etc/sys.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen2_mtu(): gre621_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" if os.path.exists("/etc/sys.sh"): with open("/etc/sys.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gen3_mtu(): private2_mtu() gre621_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGeneve \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" if os.path.exists("/etc/sys.sh"): with open("/etc/sys.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumigen mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/sys.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def private2_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[\033[96mIP6tnl\033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" if os.path.exists("/etc/private.sh"): with open("/etc/private.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumi mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/private.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def private_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mPrivate IP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" if os.path.exists("/etc/private.sh"): with open("/etc/private.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumi mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/private.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre621_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" if os.path.exists("/etc/gre6.sh"): with open("/etc/gre6.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumig6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/gre6.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre6_mtu(): private_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE6 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" if os.path.exists("/etc/gre6.sh"): with open("/etc/gre6.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumig6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/gre6.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def gre_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mGRE \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumig mtu {mtu_value}\n" if os.path.exists("/etc/gre.sh"): with open("/etc/gre.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumig mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/gre.sh", "w") as file: file.writelines(sh_contents) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def i6to4_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96m6to4 \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumi6 mtu {mtu_value}\n" if os.path.exists("/etc/6to4.sh"): with open("/etc/6to4.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumi6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/6to4.sh", "w") as file: file.writelines(sh_contents) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def i6to4any_mtu(): mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96m6to4 anycast \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumi6 mtu {mtu_value}\n" if os.path.exists("/etc/6to4.sh"): with open("/etc/6to4.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumi6 mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/6to4.sh", "w") as file: file.writelines(sh_contents) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ipip_mtu(): private_mtu() mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mIP6IP6 \033[93m]:\033[0m " ) mtu_command = f"/sbin/ip -6 link set dev azumip mtu {mtu_value}\n" if os.path.exists("/etc/ipip.sh"): with open("/etc/ipip.sh", "r") as file: sh_contents = file.readlines() mtu_exists = False for i in range(len(sh_contents)): if "link set dev azumip mtu" in sh_contents[i]: sh_contents[i] = mtu_command mtu_exists = True break if not mtu_exists: sh_contents.append(mtu_command) with open("/etc/ipip.sh", "w") as file: file.writelines(sh_contents) display_checkmark("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def ip_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIPIP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_ip_menu() break elif server_type == "2": iran_ip_menu() break elif server_type == "3": clear() main_menu() break else: print("Invalid choice.") def ip_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def ip_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ip_iran(): remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) ip_address = remote_prefix max_pings = 3 interval = 2 ip_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) ip_service() print("\033[92mIPIP6 Configuration Completed!\033[0m") def ip_kharej(): remote_ipv4 = input( "\033[93mEnter \033[92mIran IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) ip_address = remote_prefix max_pings = 3 interval = 2 ip_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) ip_service() print("\033[92mIPIP6 Configuration Completed!\033[0m") # isata # import os import re import subprocess import time import sys def ipsec_statuscheck(service_name): try: status = ( subprocess.check_output(f"systemctl is-active {service_name}", shell=True) .decode("utf-8") .strip() ) return status == "active" except subprocess.CalledProcessError: return False def check_global(interface): try: output = subprocess.check_output( f"ip -6 addr show {interface}", shell=True ).decode("utf-8") inet6_addresses = re.findall( r"inet6 (2001:db8::5efe:[\da-fA-F:]+)/64 scope global", output ) return inet6_addresses if inet6_addresses else None except subprocess.CalledProcessError: return None def isatap_status(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mISATAP Status Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭─────────────────────────────────────────────────╮\033[0m") print("\033[93mYou are viewing the status of your current tunnel:\033[0m") print("\033[93m────────────────────────────────────────\033[0m") interfaces = ["azumiserver", "azumiclient"] active_int = [] for interface in interfaces: if interface_ex(interface): status = interface_check(interface) if status: active_int.append(interface) if not active_int: print(" No Interfaces available.") elif "azumiserver" in active_int: with open("/etc/port.sh", "r") as file: contents = file.read() print( " \033[97mServer \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumiserver\033[0m" ) print(" \033[93mTunnel Method: \033[97mISATAP\033[0m") ipsec_status = ipsec_statuscheck("strong-azumi1") if ipsec_status: print(" \033[93mIPsec Status: \033[92mActive\033[0m") else: print(" \033[93mIPsec Status: \033[91mInactive\033[0m") print("\033[93m────────────────────────────────────────\033[0m") inet6_addresses = check_global("azumiserver") if inet6_addresses: for addr in inet6_addresses: print(f" \033[93mPrivate IPV6 address: \033[97m{addr}\033[0m") else: print(" \033[91mServer has no IPV6 address\033[0m") remote_ips = re.findall(r"REMOTE_IPV4_(\d+)=(\S+)", contents) if remote_ips: for idx, ip in remote_ips: print(f" \033[93mClient IP \033[96m{idx}\033[93m: \033[97m{ip}\033[0m") else: print(" \033[91mNo remote IP found\033[0m") elif "azumiclient" in active_int: with open("/etc/port.sh", "r") as file: contents = file.read() client_displayed = False for i in range(1, 6): server_file = f"/etc/server{i}.sh" if os.path.exists(server_file): print( f" \033[97mClient \033[96m{i}\033[93m Status: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumiclient\033[0m" ) client_displayed = True if not client_displayed: print( " \033[97mClient\033[93m Status: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumiclient\033[0m" ) print(" \033[93mTunnel Method: \033[97mISATAP\033[0m") ipsec_status = ipsec_statuscheck("strong-azumi1") if ipsec_status: print(" \033[93mIPsec Status: \033[92mActive\033[0m") else: print(" \033[93mIPsec Status: \033[91mInactive\033[0m") print("\033[93m────────────────────────────────────────\033[0m") inet6_addresses = check_global("azumiclient") if inet6_addresses: for addr in inet6_addresses: print(f" \033[93mPrivate IPV6 address: \033[97m{addr}\033[0m") else: print(" \033[91mClient has no IPV6 address\033[0m") remote_ips = re.findall(r"REMOTE_IPV4=(\S+)", contents) if remote_ips: for ip in remote_ips: print(f" \033[93mServer IP : \033[97m{ip}\033[0m") else: print(" \033[91mNo remote IP found\033[0m") print("\033[93m────────────────────────────────────────\033[0m") secret_key = ipsec_secret() if secret_key != "Not found": print(" \033[93mIPsec Secret Key:\033[96m", secret_key, "\033[0m") else: print(" \033[93mIPSEC is not available\033[0m") print("\033[93m─────────────────────────────────────────────────\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰─────────────────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": os.system("clear") isatap_mnu() break else: print("Invalid choice.") def isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("0. \033[91mISATAP STATUS\033[0m") print("1. \033[93mServer : Kharej | Client : IRAN\033[0m") print("2. \033[92mServer : IRAN | Client : Kharej\033[0m") print("3. \033[96mEdit MTU\033[0m") print("4. \033[93mEdit Servers\033[0m") print("5. \033[91mUninstall\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": isatap_status() break elif choice == "1": server_isatap_mnu() break elif choice == "2": client_isatap_mnu() break elif choice == "3": isatap_mtu_menu() break elif choice == "4": isatap_edit_server2() break elif choice == "5": isatap_remove_menu() break elif choice == "0": clear() main_menu() break else: print("Invalid choice.") def isatap_edit_server2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Edit Server Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mServer : Kharej | Client : IRAN\033[0m") print("2 \033[92mServer : IRAN | Client : Kharej\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": server_isatap_editmnu() break elif choice == "2": client_isatap_editmnu() break elif choice == "0": clear() isatap_mnu() break else: print("Invalid choice.") def server_isatap_editmnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | ISATAP\033[93m Edit Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mWhich one to edit:\033[0m") print("1. \033[92m Kharej Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m IRAN Client [1]\033[0m") print("3. \033[93m IRAN Client [2]\033[0m") print("4. \033[93m IRAN Client [3]\033[0m") print("5. \033[93m IRAN Client [4]\033[0m") print("6. \033[93m IRAN Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": server_isatap_rmvmnu() kharej1server_isatap_mnu() break elif choice == "2": client_isatap_rmvmnu() iranclient1_isatap_mnu() break elif choice == "3": client_isatap_rmvmnu() iranclient2_isatap_mnu() break elif choice == "4": client_isatap_rmvmnu() iranclient3_isatap_mnu() break elif choice == "5": client_isatap_rmvmnu() iranclient4_isatap_mnu() break elif choice == "6": client_isatap_rmvmnu() iranclient5_isatap_mnu() break elif choice == "0": clear() isatap_edit_server2() break else: print("Invalid choice.") def client_isatap_editmnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | ISATAP\033[93m Edit Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mWhich one to edit:\033[0m") print("1. \033[92m IRAN Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m Kharej Client [1]\033[0m") print("3. \033[93m Kharej Client [2]\033[0m") print("4. \033[93m Kharej Client [3]\033[0m") print("5. \033[93m Kharej Client [4]\033[0m") print("6. \033[93m Kharej Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": server_isatap_rmvmnu() iran1server_isatap_mnu() break elif choice == "2": client_isatap_rmvmnu() kharejclient1_isatap_mnu() break elif choice == "3": client_isatap_rmvmnu() kharejclient2_isatap_mnu() break elif choice == "4": client_isatap_rmvmnu() kharejclient3_isatap_mnu() break elif choice == "5": client_isatap_rmvmnu() kharejclient4_isatap_mnu() break elif choice == "6": client_isatap_rmvmnu() kharejclient5_isatap_mnu() break elif choice == "0": clear() isatap_edit_server2() break else: print("Invalid choice.") def isatap_mtu_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m MTU Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mServer : Kharej | Client : IRAN\033[0m") print("2 \033[92mServer : IRAN | Client : Kharej\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": server_isatap_mtumnu() break elif choice == "2": client_isatap_mtumnu() break elif choice == "0": clear() isatap_mnu() break else: print("Invalid choice.") def client_isatap_mtumnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : IRAN | Client : Kharej | MTU\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m IRAN Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m Kharej Client [1]\033[0m") print("3. \033[93m Kharej Client [2]\033[0m") print("4. \033[93m Kharej Client [3]\033[0m") print("5. \033[93m Kharej Client [4]\033[0m") print("6. \033[93m Kharej Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": kharej1server_mtuisa_mnu() break elif choice == "2": iranclient1_mtuisa_mnu() break elif choice == "3": iranclient1_mtuisa_mnu() break elif choice == "4": iranclient1_mtuisa_mnu() break elif choice == "5": iranclient1_mtuisa_mnu() break elif choice == "6": iranclient1_mtuisa_mnu() break elif choice == "0": clear() isatap_mtu_menu() break else: print("Invalid choice.") def server_isatap_mtumnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | MTU\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m Kharej Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m IRAN Client [1]\033[0m") print("3. \033[93m IRAN Client [2]\033[0m") print("4. \033[93m IRAN Client [3]\033[0m") print("5. \033[93m IRAN Client [4]\033[0m") print("6. \033[93m IRAN Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": kharej1server_mtuisa_mnu() break elif choice == "2": iranclient1_mtuisa_mnu() break elif choice == "3": iranclient1_mtuisa_mnu() break elif choice == "4": iranclient1_mtuisa_mnu() break elif choice == "5": iranclient1_mtuisa_mnu() break elif choice == "6": iranclient1_mtuisa_mnu() break elif choice == "0": clear() isatap_mtu_menu() break else: print("Invalid choice.") def kharej1server_mtuisa_mnu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Server \033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mISATAP\033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiserver mtu {mtu_value}\n" if os.path.exists("/usr/local/bin/isatap.sh"): with open("/usr/local/bin/isatap.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumiserver mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumiserver mtu" not in line ] with open("/usr/local/bin/isatap.sh", "w") as file: file.writelines(sh_contents) with open("/usr/local/bin/isatap.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def iranclient1_mtuisa_mnu(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93m Client \033[0m") print("\033[93m───────────────────────────────────────\033[0m") mtu_value = input( "\033[93mEnter the \033[92mMTU value \033[93m[ \033[96mISATAP \033[93m]:\033[0m " ) mtu_command = f"ip link set dev azumiclient mtu {mtu_value}\n" if os.path.exists("/usr/local/bin/isatap.sh"): with open("/usr/local/bin/isatap.sh", "r") as file: sh_contents = file.readlines() if any("link set dev azumiclient mtu" in line for line in sh_contents): sh_contents = [ line for line in sh_contents if "link set dev azumiclient mtu" not in line ] with open("/usr/local/bin/isatap.sh", "w") as file: file.writelines(sh_contents) with open("/usr/local/bin/isatap.sh", "a") as file: file.write(mtu_command) print("\033[92mMTU command edited successfully\033[0m") subprocess.run(mtu_command, shell=True) else: print("\033[91mCommand file doesn't exist\033[0m") def isatap_remove_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Remove Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93mServer\033[0m") print("2 \033[92mClient\033[0m") print("0. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": server_isatap_rmvmnu() break elif choice == "2": client_isatap_rmvmnu() break elif choice == "0": clear() isatap_mnu() break else: print("Invalid choice.") def client_isatap_rmvmnu(): delete_cron3() delete_cron4() ipsec_service_remove() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving ISATAP + \033[92mIpsec \033[93mClient\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving cronjob & other stuff...\033[0m") commands = [ 'crontab -l | grep -v "@reboot /bin/bash /usr/local/bin/isatap.sh" | crontab -', "sudo rm /etc/ipsec1.conf", "sudo rm /etc/ipsec2.sh", "sudo rm /etc/server1.sh", "sudo rm /etc/server2.sh", "sudo rm /etc/server3.sh", "sudo rm /etc/server4.sh", "sudo rm /etc/server5.sh", "sudo rm /usr/local/bin/ping_keepalive.sh", "sudo rm /etc/ipsec.secrets", "sudo rm /usr/bin/local/isatap.sh", "sudo rm /etc/resetbasedonping1.sh", "systemctl disable azumireset1", "systemctl stop azumireset1", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl disable isatapreset", "systemctl stop isatapreset", "sudo rm /etc/systemd/system/isatapreset.service", "sudo rm /etc/reset_isatap.sh", "sudo rm /usr/local/bin/isatap_daemon.sh", "systemctl disable isa", "systemctl stop isa", "sudo rm /etc/systemd/system/isa.service", "systemctl disable radvd", "systemctl stop radvd", "systemctl disable strong-azumi1", "systemctl stop strong-azumi1", "sudo rm /etc/systemd/system/strong-azumi1.service", "ip link set dev azumiclient down", "ip link delete azumiclient", "ip link delete sit0", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) hide("apt purge strongswan -y") hide("apt purge radvd -y") ports = [] if os.path.exists("/etc/port.sh"): with open("/etc/port.sh", "r") as f: content = f.read().strip() for line in content.split("\n"): if line.startswith("PORT="): ports.append(line.split("=")[1]) for port in ports: subprocess.run(f"sudo ufw delete allow {port}", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def server_isatap_rmvmnu(): delete_cron3() delete_cron4() ipsec_service_remove() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving ISATAP + \033[92mIpsec \033[93mServer\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") display_notification("\033[93mRemoving cronjob & other stuff...\033[0m") commands = [ 'crontab -l | grep -v "@reboot /bin/bash /usr/local/bin/isatap.sh" | crontab -', "sudo rm /etc/ipsec1.conf", "sudo rm /etc/ipsec2.sh", "sudo rm /etc/server1.sh", "sudo rm /usr/local/bin/ping_keepalive.sh", "sudo rm /usr/local/bin/ping_keepalive_1.sh", "sudo rm /usr/local/bin/ping_keepalive_2.sh", "sudo rm /usr/local/bin/ping_keepalive_3.sh", "sudo rm /usr/local/bin/ping_keepalive_4.sh", "sudo rm /usr/local/bin/ping_keepalive_5.sh", "sudo rm /etc/ipsec.secrets", "sudo rm /usr/bin/local/isatap.sh", "sudo rm /etc/resetbasedonping1.sh", "systemctl disable azumireset1", "systemctl stop azumireset1", "sudo rm /etc/systemd/system/azumireset1.service", "systemctl disable isatapreset", "systemctl stop isatapreset", "sudo rm /etc/systemd/system/isatapreset.service", "sudo rm /etc/reset_isatap.sh", "sudo rm /usr/local/bin/isatap_daemon.sh", "systemctl disable isa_1", "systemctl stop isa_1", "sudo rm /etc/systemd/system/isa_1.service", "systemctl disable isa_2", "systemctl stop isa_2", "sudo rm /etc/systemd/system/isa_2.service", "systemctl disable isa_3", "systemctl stop isa_3", "sudo rm /etc/systemd/system/isa_3.service", "systemctl disable isa_4", "systemctl stop isa_4", "sudo rm /etc/systemd/system/isa_4.service", "systemctl disable isa_5", "systemctl stop isa_5", "sudo rm /etc/systemd/system/isa_5.service", "systemctl disable radvd", "systemctl stop radvd", "systemctl disable strong-azumi1", "systemctl stop strong-azumi1", "sudo rm /etc/systemd/system/strong-azumi1.service", "ip link set dev azumiserver down", "ip link delete azumiserver", "ip link delete sit0", "systemctl daemon-reload", ] for command in commands: subprocess.run(command, shell=True, stdout=devnull, stderr=devnull) hide("apt purge strongswan -y") hide("apt purge radvd -y") ports = [] if os.path.exists("/etc/port.sh"): with open("/etc/port.sh", "r") as f: content = f.read().strip() for line in content.split("\n"): if line.startswith("PORT="): ports.append(line.split("=")[1]) for port in ports: subprocess.run(f"sudo ufw delete allow {port}", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def server_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | ISATAP\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93m[1] Kharej [5]IRAN\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": kharej1_isatap_mnu() break elif choice == "0": clear() isatap_mnu() break else: print("Invalid choice.") def kharej1_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | ISATAP\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m Kharej Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m IRAN Client [1]\033[0m") print("3. \033[93m IRAN Client [2]\033[0m") print("4. \033[93m IRAN Client [3]\033[0m") print("5. \033[93m IRAN Client [4]\033[0m") print("6. \033[93m IRAN Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": kharej1server_isatap_mnu() break elif choice == "2": iranclient1_isatap_mnu() break elif choice == "3": iranclient2_isatap_mnu() break elif choice == "4": iranclient3_isatap_mnu() break elif choice == "5": iranclient4_isatap_mnu() break elif choice == "6": iranclient5_isatap_mnu() break elif choice == "0": clear() server_isatap_mnu() break else: print("Invalid choice.") def client_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : IRAN | Client : Client | ISATAP\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1 \033[93m[1] IRAN [5]Kharej\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": iran1_isatap_mnu() break elif choice == "0": clear() isatap_mnu break else: print("Invalid choice.") def iran1_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mServer : Kharej | Client : IRAN | ISATAP\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m IRAN Server [1]\033[0m") print("\033[93m───────────────────────────────────────\033[0m") print("2. \033[93m Kharej Client [1]\033[0m") print("3. \033[93m Kharej Client [2]\033[0m") print("4. \033[93m Kharej Client [3]\033[0m") print("5. \033[93m Kharej Client [4]\033[0m") print("6. \033[93m Kharej Client [5]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "1": iran1server_isatap_mnu() break elif choice == "2": kharejclient1_isatap_mnu() break elif choice == "3": kharejclient2_isatap_mnu() break elif choice == "4": kharejclient3_isatap_mnu() break elif choice == "5": kharejclient4_isatap_mnu() break elif choice == "6": kharejclient5_isatap_mnu() break elif choice == "0": clear() client_isatap_mnu() break else: print("Invalid choice.") def animate(message): for char in message: print(char, end="", flush=True) time.sleep(0.05) print() def anime(): animation = [ "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[======]", "[===== ]", "[==== ]", "[=== ]", "[== ]", "[= ]", ] for i in range(20): time.sleep(0.1) sys.stdout.write(f"\r{animation[i % len(animation)]}") sys.stdout.flush() sys.stdout.write("\r") sys.stdout.flush() def hide(command): process = subprocess.Popen( command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE ) while process.poll() is None: anime() _, stderr = process.communicate() if process.returncode != 0: print(f"\033[91merror: {stderr.decode()}\033[0m") def forward(): with open("/proc/sys/net/ipv4/ip_forward", "r") as f: ipv4_forwarding = f.read().strip() with open("/proc/sys/net/ipv6/conf/all/forwarding", "r") as f: ipv6_forwarding = f.read().strip() if ipv4_forwarding == "0": display_notification("\033[93mEnabling IPv4 forwarding..\033[0m") os.system("echo 1 > /proc/sys/net/ipv4/ip_forward") else: print("\033[93mIPv4 forwarding is already enabled\033[0m") if ipv6_forwarding == "0": display_notification("\033[93mEnabling IPv6 forwarding..\033[0m") os.system("echo 1 > /proc/sys/net/ipv6/conf/all/forwarding") else: print("\033[93mIPv6 forwarding is already enabled\033[0m") def isa_cronjob(): try: subprocess.run( "crontab -l | grep -v '/usr/local/bin/isatap.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /usr/local/bin/isatap.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_isatap_client(local_ipv4, remote_ipv4): client_path = "/usr/local/bin/isatap.sh" mtu_command = "" set_mtu = input( "\033[93mDo you want to set MTU? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if set_mtu in ["yes", "y"]: mtu_value = input("\033[93mEnter the MTU value: \033[0m") mtu_command = f"ip link set dev azumiclient mtu {mtu_value}\n" script_content = f"""#!/bin/bash ip tunnel add azumiclient mode isatap local {local_ipv4} remote {remote_ipv4} ttl 64 ip link set azumiclient up ip addr add 2001:db8::5efe:{local_ipv4}/64 dev azumiclient {mtu_command} """ with open(client_path, "w") as file: file.write(script_content) subprocess.run(["chmod", "+x", client_path], check=True) subprocess.run(["bash", client_path], check=True) def create_isatap_server(local_ipv4): server_path = "/usr/local/bin/isatap.sh" mtu_command = "" set_mtu = input( "\033[93mDo you want to set MTU? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if set_mtu in ["yes", "y"]: mtu_value = input("\033[93mEnter the MTU value: \033[0m") mtu_command = f"ip link set dev azumiserver mtu {mtu_value}\n" script_content = f"""#!/bin/bash ip tunnel add azumiserver mode isatap local {local_ipv4} ttl 64 ip link set azumiserver up ip addr add 2001:db8::5efe:{local_ipv4}/64 dev azumiserver {mtu_command} """ with open(server_path, "w") as file: file.write(script_content) subprocess.run(["chmod", "+x", server_path], check=True) subprocess.run(["bash", server_path], check=True) def ping_keepalive(client_ip, client_index): file_path = f"/usr/local/bin/ping_keepalive_{client_index}.sh" script_content = f"""#!/bin/bash ip_address="{client_ip}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" '{{print $2}}' | awk -F " " '{{print $1}}' | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) subprocess.run(["chmod", "+x", file_path], check=True) def ping_keepalive2(server_ipv6): file_path = f"/usr/local/bin/ping_keepalive.sh" script_content = f"""#!/bin/bash ip_address="{server_ipv6}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" '{{print $2}}' | awk -F " " '{{print $1}}' | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) subprocess.run(["chmod", "+x", file_path], check=True) def ufwport(port): subprocess.run(["sudo", "ufw", "allow", port]) def isa_service2(): service_content = f"""[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /usr/local/bin/ping_keepalive.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = f"/etc/systemd/system/isa.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "isa.service"]) subprocess.run(["systemctl", "start", "isa"]) time.sleep(1) subprocess.run(["systemctl", "restart", "isa"]) def isa_service(client_index): service_content = f"""[Unit] Description=keepalive_{client_index} After=network.target [Service] ExecStart=/bin/bash /usr/local/bin/ping_keepalive_{client_index}.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = f"/etc/systemd/system/isa_{client_index}.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", f"isa_{client_index}.service"]) subprocess.run(["systemctl", "start", f"isa_{client_index}"]) time.sleep(1) subprocess.run(["systemctl", "restart", f"isa_{client_index}"]) def isatap_client(local_ipv4, remote_ipv4): os.system( f"ip tunnel add azumiclient mode isatap local {local_ipv4} remote {remote_ipv4} ttl 64" ) os.system("ip link set azumiclient up") os.system(f"ip addr add 2001:db8::5efe:{local_ipv4}/64 dev azumiclient") def isatap_server(local_ipv4): os.system(f"ip tunnel add azumiserver mode isatap local {local_ipv4} ttl 64") os.system("ip link set azumiserver up") os.system(f"ip addr add 2001:db8::5efe:{local_ipv4}/64 dev azumiserver") def install_radvd(): animate("\033[93mInstalling rad..\033[0m") hide("sudo apt-get install radvd -y") animate("\033[92mInstallation was successful!\033[0m") radvd_config = """interface azumiserver { AdvSendAdvert on; UnicastOnly on; AdvHomeAgentFlag off; prefix 2001:db8::/64 { AdvOnLink on; AdvAutonomous on; AdvRouterAddr off; }; };""" with open("/etc/radvd.conf", "w") as f: f.write(radvd_config) hide("systemctl daemon-reload") hide("systemctl enable radvd") hide("systemctl restart radvd") def install_ipvsadm(): animate("\033[93mInstalling ip..\033[0m") hide("sudo apt-get install ipvsadm -y") animate("\033[92mInstallation was successful!\033[0m") def isaaddress(name): result = subprocess.run( ["ip", "-6", "addr", "show", name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) if result.returncode != 0: return None output = result.stdout.decode() for line in output.splitlines(): if "inet6" in line and "scope global" in line: return line.split()[1].split("/")[0] return None def service_exists(service_name): result = subprocess.run( ["systemctl", "list-units", "--full", "--all", service_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) return service_name in result.stdout.decode() def config_server(psk, server_ipv6, iran_servers): print("\033[93m─────────────────────────────────────────────────────────\033[0m") animate("\033[93mInstalling IPSEC..\033[0m") hide("sudo apt install strongswan -y") animate("\033[92mIPSEC Installation is completed!\033[0m") if service_exists("strongswan-starter.service"): cmd("sudo systemctl disable strongswan-starter") cmd("sudo systemctl stop strongswan-starter") if service_exists("strongswan.service"): cmd("sudo systemctl disable strongswan") cmd("sudo systemctl stop strongswan") cmd("sudo rm -f /etc/ipsec1.conf /etc/ipsec.secrets") ipsec_conf = """config setup ##azumiisinyourarea charondebug="all" uniqueids=no """ secrets_conf = "" for i, (client_ip, _) in enumerate(iran_servers, start=1): unique_server_ipv6 = f"{server_ipv6[:-2]}{i:02x}/64" ipsec_conf += f""" conn ISATAP_server{i} left=%defaultroute leftsubnet={unique_server_ipv6} leftid={unique_server_ipv6[:-3]} right={client_ip} rightsubnet={client_ip}/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no """ secrets_conf += f'{client_ip} {unique_server_ipv6[:-3]} : PSK "{psk}"\n' with open("/etc/ipsec1.conf", "w") as f: f.write(ipsec_conf) with open("/etc/ipsec.secrets", "w") as f: f.write(secrets_conf) service_content = """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write(service_content) cmd("sudo systemctl daemon-reload") cmd("sudo systemctl enable strong-azumi1") cmd("sudo systemctl restart strong-azumi1") def config_client(psk, server_ipv6, client_ipv6): print("\033[93m─────────────────────────────────────────────────────────\033[0m") animate("\033[93mInstalling IPSEC..\033[0m") hide("sudo apt install strongswan -y") animate("\033[92mIPSEC Installation is completed!\033[0m") if service_exists("strongswan-starter.service"): cmd("sudo systemctl disable strongswan-starter") cmd("sudo systemctl stop strongswan-starter") if service_exists("strongswan.service"): cmd("sudo systemctl disable strongswan") cmd("sudo systemctl stop strongswan") cmd("sudo rm -f /etc/ipsec1.conf /etc/ipsec.secrets") ipsec_conf = f"""config setup ##azumiisinyourarea conn localtun_server left=%defaultroute leftsubnet={client_ipv6}/64 leftid={client_ipv6} right={server_ipv6} rightsubnet={server_ipv6}/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no """ with open("/etc/ipsec1.conf", "w") as f: f.write(ipsec_conf) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{server_ipv6} {client_ipv6} : PSK "{psk}"\n') service_content = """[Unit] Description=strongazumi IPsec IKEv1/IKEv2 daemon using ipsec.conf After=network-online.target [Service] ExecStart=/usr/sbin/ipsec start --nofork --conf /etc/ipsec1.conf ExecReload=/usr/sbin/ipsec reload Restart=always RestartSec=5 LimitNOFILE=1048576 [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/strong-azumi1.service", "w") as f: f.write(service_content) cmd("sudo systemctl daemon-reload") cmd("sudo systemctl enable strong-azumi1") cmd("sudo systemctl restart strong-azumi1") def load_balance(server_ipv6, iran_servers): file_path = "/usr/local/bin/isatap.sh" lb_script = "\n\n# Azumi at your service\n" for i, (client_ip, port) in enumerate(iran_servers, start=1): lb_script += f""" ipvsadm -A -t [{server_ipv6}]:{port} -s wrr ipvsadm -a -t [{server_ipv6}]:{port} -r [{client_ip}]:{port} -g """ with open(file_path, "a") as file: file.write(lb_script) def ipv6_box_iran(interface): ipv6_address = isaaddress(interface) if ipv6_address: print( "\033[93m─────────────────────────────────────────────────────────\033[0m" ) print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") print("\033[92m+---------------------------+\033[0m") print(f"\033[92m| {ipv6_address} |\033[0m") print("\033[92m+---------------------------+\033[0m") def ipv6_box_kharej(interface): ipv6_address = isaaddress(interface) if ipv6_address: print( "\033[93m─────────────────────────────────────────────────────────\033[0m" ) print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") print("\033[92m+---------------------------+\033[0m") print(f"\033[92m| {ipv6_address} |\033[0m") print("\033[92m+---------------------------+\033[0m") def ping_server(server_ipv6): display_notification("\033[96mAzumi is pinging..\033[0m") result = subprocess.run( ["ping", "-c", "2", server_ipv6], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) return True else: print(f"\033[91mPing failed: {result.stderr}\033[0m") return False def choose_reset3(): print("\033[93mChoose IPSEC reset timer:\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") reset_unit = input("\033[93mEnter your choice (1 or 2): \033[0m") if reset_unit == "1": reset2_hour() elif reset_unit == "2": reset2_minutes() else: print("\033[91mInvalid choice. Please enter 1 or 2.\033[0m") def reset_local(interval): service_name = "isatapreset.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_isatap.sh sleep $INTERVAL done """ with open("/usr/local/bin/isatap_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/isatap_daemon.sh"]) service_content = f"""[Unit] Description=Custom IPSEC Daemon [Service] ExecStart=/usr/local/bin/isatap_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link delete azumiserver /bin/bash /usr/local/bin/isatap.sh sudo systemctl restart strong-azumi1 """ with open("/etc/reset_isatap.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_isatap.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "--now", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_local2(interval): service_name = "isatapreset.service" daemon_script_content = f"""#!/bin/bash INTERVAL={interval} while true; do /bin/bash /etc/reset_isatap.sh sleep $INTERVAL done """ with open("/usr/local/bin/isatap_daemon.sh", "w") as daemon_script_file: daemon_script_file.write(daemon_script_content) subprocess.run(["chmod", "+x", "/usr/local/bin/isatap_daemon.sh"]) service_content = f"""[Unit] Description=Custom IPSEC Daemon [Service] ExecStart=/usr/local/bin/isatap_daemon.sh Restart=always [Install] WantedBy=multi-user.target """ with open(f"/etc/systemd/system/{service_name}", "w") as service_file: service_file.write(service_content) ipsec_reset_script_content = """#!/bin/bash ip link delete azumiclient /bin/bash /usr/local/bin/isatap.sh sudo systemctl restart strong-azumi1 """ with open("/etc/reset_isatap.sh", "w") as script_file: script_file.write(ipsec_reset_script_content) subprocess.run(["chmod", "+x", "/etc/reset_isatap.sh"]) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "--now", service_name]) subprocess.run(["systemctl", "restart", service_name]) def reset_ping_isatapclient(client_ipv6_list): ping_commands = "\n".join( [f" ping -c 2 {ipv6} >/dev/null 2>&1" for ipv6 in client_ipv6_list] ) script_content = f"""#!/bin/bash while true; do {ping_commands} if [ $? -ne 0 ]; then /bin/bash /etc/reset_isatap.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def resetping_service_isatap(): service_content = """[Unit] Description=Azumi local Service reset After=network.target [Service] Type=simple Restart=always LimitNOFILE=1048576 ExecStart=/etc/resetbasedonping1.sh [Install] WantedBy=multi-user.target """ with open("/etc/systemd/system/azumireset1.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "azumireset1"]) subprocess.run(["systemctl", "restart", "azumireset1"]) def iran1server_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Server\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() install_radvd() install_ipvsadm() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") create_isatap_server(local_ipv4) isa_cronjob() interface = "azumiserver" ipv6_box_kharej(interface) print("\033[93m────────────────────────────────────────\033[0m") kharej_servers_count = int( input("\033[93mHow many \033[92mKharej \033[93mClients do you have? \033[0m") ) kharej_servers_data = [] client_ipv6_list = [] for i in range(1, kharej_servers_count + 1): remote_ipv4 = input( f"\033[93mEnter \033[92mKharej \033[96m{i} \033[93mIPv4 address:\033[0m " ) client_ipv6 = prefix(remote_ipv4) client_ipv6_list.append(client_ipv6) port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m{i}\033[93m: \033[0m" ) with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4_{i}={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) kharej_servers_data.append((client_ipv6, port)) server_ipv6 = isaaddress("azumiserver") if not server_ipv6: print("\033[91mNo IPv6 address for azumiserver found\033[0m") return load_balance(server_ipv6, kharej_servers_data) print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_server(psk, server_ipv6, kharej_servers_data) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") for index, (client_ipv6, _) in enumerate(kharej_servers_data, start=1): ping_keepalive(client_ipv6, index) isa_service(index) print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local(interval_seconds) reset_ping_isatapclient(client_ipv6_list) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Server Configuration is completed!\033[0m") def kharej1server_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Server\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() install_radvd() install_ipvsadm() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") create_isatap_server(local_ipv4) isa_cronjob() interface = "azumiserver" ipv6_box_kharej(interface) print("\033[93m────────────────────────────────────────\033[0m") iran_servers_count = int( input("\033[93mHow many \033[92mIRAN \033[93mClients do you have? \033[0m") ) iran_servers_data = [] client_ipv6_list = [] for i in range(1, iran_servers_count + 1): remote_ipv4 = input( f"\033[93mEnter \033[92mIRAN \033[96m{i} \033[93mIPv4 address:\033[0m " ) client_ipv6 = prefix(remote_ipv4) client_ipv6_list.append(client_ipv6) port = input( f"\033[93mEnter the port for \033[92mIRAN \033[96m{i}\033[93m: \033[0m" ) with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4_{i}={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) iran_servers_data.append((client_ipv6, port)) server_ipv6 = isaaddress("azumiserver") if not server_ipv6: print("\033[91mNo IPv6 address for azumiserver found\033[0m") return load_balance(server_ipv6, iran_servers_data) print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_server(psk, server_ipv6, iran_servers_data) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() for index, (client_ipv6, _) in enumerate(iran_servers_data, start=1): ping_keepalive(client_ipv6, index) isa_service(index) print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local(interval_seconds) reset_ping_isatapclient(client_ipv6_list) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Server Configuration is completed!\033[0m") def prefix(ipv4): octets = ipv4.split(".") hex_parts = [format(int(octet), "02x") for octet in octets] return f"2001:db8::5efe:{hex_parts[0]}{hex_parts[1]}:{hex_parts[2]}{hex_parts[3]}" def iranclient1_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Client [1]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mIRAN \033[96m[1]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") port = input(f"\033[93mEnter the port for \033[92mIRAN \033[96m1\033[93m: \033[0m") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_iran(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server1.sh"): os.remove("/etc/server1.sh") with open("/etc/server1.sh", "w") as f: f.write(f"server=1\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Client 1 Configuration is completed!\033[0m") def reset_ping_isatapserver(server_ipv6): script_content = f"""#!/bin/bash while true; do ping -c 2 {server_ipv6} >/dev/null 2>&1 if [ $? -ne 0 ]; then /bin/bash /etc/reset_isatap.sh fi sleep 5 done """ with open("/etc/resetbasedonping1.sh", "w") as f: f.write(script_content) os.chmod("/etc/resetbasedonping1.sh", 0o755) def iranclient2_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Client [2]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mIRAN \033[96m[2]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") port = input(f"\033[93mEnter the port for \033[92mIRAN \033[96m2\033[93m: \033[0m") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_iran(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server1.sh"): os.remove("/etc/server2.sh") with open("/etc/server2.sh", "w") as f: f.write(f"server=2\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Client 2 Configuration is completed!\033[0m") def iranclient3_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Client [3]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mIRAN \033[96m[3]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") port = input(f"\033[93mEnter the port for \033[92mIRAN \033[96m3\033[93m: \033[0m") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_iran(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server3.sh"): os.remove("/etc/server3.sh") with open("/etc/server3.sh", "w") as f: f.write(f"server=3\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Client 3 Configuration is completed!\033[0m") def iranclient4_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Client [4]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mIRAN \033[96m[4]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") port = input(f"\033[93mEnter the port for \033[92mIRAN \033[96m4\033[93m: \033[0m") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_iran(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server4.sh"): os.remove("/etc/server4.sh") with open("/etc/server4.sh", "w") as f: f.write(f"server=4\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Client 4 Configuration is completed!\033[0m") def iranclient5_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m IRAN Client [5]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mIRAN \033[96m[5]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m Server IPV4: \033[0m") port = input(f"\033[93mEnter the port for \033[92mIRAN \033[96m5\033[93m: \033[0m") if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_iran(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server5.sh"): os.remove("/etc/server5.sh") with open("/etc/server5.sh", "w") as f: f.write(f"server=5\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mIRAN Client 5 Configuration is completed!\033[0m") # kharej client def kharejclient1_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Client [1]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mKharej \033[96m[1]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m1\033[93m: \033[0m" ) if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_kharej(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server1.sh"): os.remove("/etc/server1.sh") with open("/etc/server1.sh", "w") as f: f.write(f"server=1\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Client 1 Configuration is completed!\033[0m") def kharejclient2_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Client [2]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mKharej \033[96m[2]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m2\033[93m: \033[0m" ) if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_kharej(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server2.sh"): os.remove("/etc/server2.sh") with open("/etc/server2.sh", "w") as f: f.write(f"server=2\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Client 2 Configuration is completed!\033[0m") def kharejclient3_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Client [3]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mKharej \033[96m[3]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m3\033[93m: \033[0m" ) if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_kharej(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server3.sh"): os.remove("/etc/server3.sh") with open("/etc/server3.sh", "w") as f: f.write(f"server=3\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Client 3 Configuration is completed!\033[0m") def kharejclient4_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Client [4]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mKharej \033[96m[4]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m4\033[93m: \033[0m" ) if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_kharej(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m):\033[0m " ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server4.sh"): os.remove("/etc/server4.sh") with open("/etc/server4.sh", "w") as f: f.write(f"server=4\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Client 4 Configuration is completed!\033[0m") def kharejclient5_isatap_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mISATAP\033[93m Kharej Client [5]\033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') forward() print("\033[93m────────────────────────────────────────\033[0m") local_ipv4 = input( "\033[93mEnter \033[92mKharej \033[96m[5]\033[93m Client IPV4: \033[0m" ) remote_ipv4 = input("\033[93mEnter \033[92mIRAN\033[93m Server IPV4: \033[0m") port = input( f"\033[93mEnter the port for \033[92mKharej \033[96m5\033[93m: \033[0m" ) if os.path.exists("/etc/port.sh"): os.remove("/etc/port.sh") with open("/etc/port.sh", "a") as f: f.write(f"REMOTE_IPV4={remote_ipv4}\n") f.write(f"PORT={port}\n") ufwport(port) if os.path.exists("/usr/local/bin/isatap.sh"): os.remove("/usr/local/bin/isatap.sh") create_isatap_client(local_ipv4, remote_ipv4) isa_cronjob() server_ipv6 = prefix(remote_ipv4) interface = "azumiclient" ipv6_box_kharej(interface) client_ipv6 = isaaddress("azumiclient") if not client_ipv6: print("\033[91mNo IPv6 address for azumiclient found\033[0m") return print("\033[93m────────────────────────────────────────\033[0m") ipsec_enable = input( "\033[93mDo you want \033[92mIPSEC Encryption \033[93mto be enabled ? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if ipsec_enable in ["yes", "y"]: psk = input("\033[93mEnter \033[92mIPSEC \033[93mSecret Key :\033[0m ") config_client(psk, server_ipv6, client_ipv6) print("\033[93m────────────────────────────────────────\033[0m") enable_reset_ipsec() print("\033[93m────────────────────────────────────────\033[0m") ping_server(server_ipv6) ping_keepalive2(server_ipv6) isa_service2() if os.path.exists("/etc/server5.sh"): os.remove("/etc/server5.sh") with open("/etc/server5.sh", "w") as f: f.write(f"server=5\n") print("\033[93m────────────────────────────────────────\033[0m") enable_reset = input( "\033[93mDo you want to enable \033[96mISATAP \033[92mreset time\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ).lower() if enable_reset in ["yes", "y"]: print("\033[93m╭───────────────────────────────────────╮\033[0m") print("1. \033[92mHour\033[0m") print("2. \033[93mMinute\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") time_unit_choice = input("\033[93mEnter your choice :\033[0m ").strip() if time_unit_choice == "1": time_unit = "hour" elif time_unit_choice == "2": time_unit = "minute" else: print("\033[91mWrong choice\033[0m") return time_value = input( "\033[93mEnter the \033[92mdesired input\033[93m:\033[0m " ).strip() interval_seconds = ( int(time_value) * 3600 if time_unit == "hour" else int(time_value) * 60 ) reset_local2(interval_seconds) reset_ping_isatapserver(server_ipv6) resetping_service_isatap() print("\033[93m────────────────────────────────────────\033[0m") animate("\033[92mKharej Client 5 Configuration is completed!\033[0m") def cmd(command): subprocess.run(command, shell=True, check=True) ## kharej ip def server_ipv4(): command = "curl -s https://api.ipify.org" process = subprocess.run(command, shell=True, capture_output=True, text=True) if process.returncode != 0: print("Error retrieving server's IPv4 address.") return None ipv4 = process.stdout.strip() return ipv4 def kharej_ip_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIPIP \033[92mKharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') file_path = "/etc/ip.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int(input("Enter the number of additional IPv6 addresses: ")) command = f"echo '/sbin/modprobe sit' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip tunnel add azumii mode ipip remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add {ipv6}/16 dev azumii' >> {file_path}" subprocess.run(command, shell=True, check=True) for i in range(2, num_additional_ips + 2): ip_address = f"{ipv6[:-1]}{i}/16" command = f"echo 'ip addr add {ip_address} dev azumii' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumii up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) config_file_path = "/etc/ip.sh" subprocess.run( f"(crontab -l | grep -v -F '{file_path}') | crontab -", shell=True, check=True ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) print("GRE tunnel created and configured successfully.") print("Configuration saved to /etc/ip.sh.") print("Cronjob added to execute /etc/ip.sh on every reboot.") ip_kharej() # iran ip def iran_ip_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIPIP \033[92mIRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') file_path = "/etc/ip.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int(input("Enter the number of additional IPv6 addresses: ")) command = f"echo '/sbin/modprobe sit' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip tunnel add azumii mode ipip remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add {ipv6}/16 dev azumii' >> {file_path}" subprocess.run(command, shell=True, check=True) for i in range(2, num_additional_ips + 2): ip_address = f"{ipv6[:-1]}{i}/16" command = f"echo 'ip addr add {ip_address} dev azumii' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumii up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) config_file_path = "/etc/ip.sh" subprocess.run( f"(crontab -l | grep -v -F '{file_path}') | crontab -", shell=True, check=True ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) print("GRE tunnel created and configured successfully.") print("Configuration saved to /etc/ip.sh.") print("Cronjob added to execute /etc/ip.sh on every reboot.") ip_iran() ###menu ipip def ipip_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIPIP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnussingle() kharej_ipip6_menu() break elif server_type == "2": ipip6_reset_rmvmnussingle() iran_ipip6_menu() break elif server_type == "3": clear() singleserver_mnu() break else: print("Invalid choice.") def run_ping(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) def display_kharej_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "fd1d:fc98:b73e:b481::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron_job(): file_path = "/etc/private.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) ##ipip6 kharej def ping_ipip_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def ipip6_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a220::1/64 dev azumip' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumip' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::1\n".format( interface ) with open("/etc/ipip.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip mtu {mtu_value}\n" with open("/etc/ipip.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses :\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a220::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip6_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ipip' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumip mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 addr add 2002:0db8:1234:a220::1/64 dev azumip' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumip up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = ( f"echo 'ip -6 route add 2002:0db8:1234:a220::2/64 dev azumip' >> {file_path}" ) subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::1\n".format( interface ) with open("/etc/ipip.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip mtu {mtu_value}\n" with open("/etc/ipip.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses :\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:0db8:1234:a220::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def create_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip_kharej(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip6_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::2" # iranip max_pings = 3 interval = 2 create_ping_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip_service() ipip_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip_kharejsec(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip6_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a220::2" # iranip max_pings = 3 interval = 2 create_ping_script(ip_address, max_pings, interval) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_ipip_service() ipip_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit kharej def kharej_ipip6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip_kharej() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### IRAN IPIP6 def iran_pingg(): try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::1"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def display_iran_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "fd1d:fc98:b73e:b481::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") ##ipip6 iran def iran_ipip_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def ipip6_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/ipip.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip\n") f.write("ip link set azumip up\n") f.write("ip -6 route add 2002::/16 dev azumip\n") created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:0db8:1234:a22{i}::2" created_ips.append(ip_address) f.write(f"ip -6 addr add {ip_address}/64 dev azumip\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::2\n".format( interface ) with open("/etc/ipip.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip mtu {mtu_value}\n" with open("/etc/ipip.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip6_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/ipip.sh" if os.path.exists(file_path): os.remove(file_path) with open(file_path, "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumip mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 addr add 2002:0db8:1234:a220::2/64 dev azumip\n") f.write("ip link set azumip up\n") f.write("ip -6 route add 2002:0db8:1234:a220::1/64 dev azumip\n") command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:0db8:1234:a220::2\n".format( interface ) with open("/etc/ipip.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [IP6IP6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumip mtu {mtu_value}\n" with open("/etc/ipip.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + "| 2002:0db8:1234:a220::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def ipip_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/ipip.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/ipip.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def iran_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def ipip_iran(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej-ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("\033[93mHow many \033[92madditional ips\033[93m do you need? \033[0m") ) ipip6_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip_service() ipip_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") def ipip_iransec(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej-ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipip6_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:0db8:1234:a220::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_ipip_service() ipip_cronjob() display_checkmark("\033[92mIPIP6 Configuration Completed!\033[0m") # sit iran def iran_ipip6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring IPIP6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi\n") print("\033[93m─────────────────────────────────────────────────────────\033[0m") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip_iran() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##### PRIVATE & NATIVE def private_ip_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mPrivate IP Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnusingle() kharej_private_menu() break elif server_type == "2": private_reset_rmvmnusingle() iran_private_menu() break elif server_type == "3": clear() singleserver_mnu() break else: print("Invalid choice.") def run_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "2002:831b::2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def run_ping_iran(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "2002:831b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) def kharej_private_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m There is also a cronjob and a ping service that automatically installs" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "-6", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) num_ips = int( input("\033[93mHow many \033[92mprivate IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" result = subprocess.run( ["ip", "-6", "addr", "show", "dev", "azumi"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "-6", "addr", "add", ip_addr, "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::1/64 dev azumi\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1/64" f.write(f"ip -6 addr add {ip_addr} dev azumi\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::1\n".format( interface ) with open("/etc/private.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_private_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Iran server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m There is also a cronjob and a ping service that automatically installs" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "-6", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) num_ips = int( input("\033[93mHow many \033[92mprivate IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" result = subprocess.run( ["ip", "-6", "addr", "show", "dev", "azumi"], capture_output=True, text=True ) if ip_addr in result.stdout: print(f"IP address {ip_addr} already exists. Skipping...") else: subprocess.run( ["ip", "-6", "addr", "add", ip_addr, "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::2/64 dev azumi\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi\n") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2/64" f.write(f"ip -6 addr add {ip_addr} dev azumi\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::2\n".format( interface ) with open("/etc/private.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") for i in range(1, num_ips + 1): ip_suffix = hex(i)[2:] ip_addr = f"2002:83{ip_suffix}b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() ## Native def Native_menu(): subprocess.run("clear", shell=True) print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mNative IP Menu\033[0m") print('\033[92m "-"\033[93m═════════════════════\033[0m') print( "\033[93m.-------------------------------------------------------------------------------------------------------.\033[0m" ) print( "\033[93m| \033[92mIf it didn't work, please uninstall it and add extra IP manually \033[0m" ) print( "\033[93m|\033[0m If you don't have native IPv6, please use a private IP instead. \033[0m" ) print( "\033[93m'-------------------------------------------------------------------------------------------------------'\033[0m" ) display_notification("\033[93mAdding extra Native IPv6 [Kharej]...\033[0m") print("\033[93m╭──────────────────────────────────────────────────────────╮\033[0m") try: interface = subprocess.run( "ip route | awk '/default/ {print $5; exit}'", shell=True, capture_output=True, text=True, ).stdout.strip() ipv6_addresses = ( subprocess.run( f"ip -6 addr show dev {interface} | awk '/inet6 .* global/ {{print $2}}' | cut -d'/' -f1", shell=True, capture_output=True, text=True, ) .stdout.strip() .split("\n") ) print("\033[92mCurrent IPv6 addresses on", interface + ":\033[0m") for address in ipv6_addresses: print(address) confirm = input("\033[93mAre these your current IPv6 addresses? (y/n): \033[0m") if confirm.lower() != "y": display_error( "\033[91mAborted. Please manually configure the correct IPv6 addresses.\033[0m" ) return sorted_addresses = sorted(ipv6_addresses, reverse=True) additional_address = "" for i in range(len(sorted_addresses)): current_last_part = sorted_addresses[i].split(":")[-1] modified_last_part_hex = format(int(current_last_part, 16) + 1, "04x") modified_address = ( ":".join(sorted_addresses[i].split(":")[:-1]) + ":" + modified_last_part_hex ) if modified_address not in sorted_addresses: additional_address = modified_address break if not additional_address: display_error("\033[91mNo additional address to add.\033[0m") return subprocess.run( ["ip", "addr", "add", f"{additional_address}/64", "dev", interface] ) script_file = "/etc/ipv6.sh" with open(script_file, "a") as file: file.write(f"ip addr add {additional_address}/64 dev {interface}\n") subprocess.run(["chmod", "+x", script_file]) subprocess.run("crontab -l | grep -v '/etc/ipv6.sh' | crontab -", shell=True) display_notification("\033[93mAdding cronjob for the server..\033[0m") subprocess.run( '(crontab -l 2>/dev/null; echo "@reboot /bin/bash /etc/ipv6.sh") | crontab -', shell=True, ) display_checkmark("\033[92mIPv6 addresses added successfully!\033[0m") except ValueError as e: display_error( "\033[91mAn error occurred while adding IPv6 addresses:", str(e), "\033[0m" ) ###menu gre def gre_gre6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE | GRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE\033[0m") print("2. \033[93mGRE6 \033[0m") print("3. \033[94mback to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre_menu() break elif server_type == "2": gre6_menu() break elif server_type == "3": clear() main_menu() break else: print("Invalid choice.") def gre_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_gre_menu() break elif server_type == "2": iran_gre_menu() break elif server_type == "3": clear() singleserver_mnu() break else: print("Invalid choice.") def gre6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6 Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnusingle() kharej_gre6_menu() break elif server_type == "2": gre6_reset_rmvmnusingle() iran_gre6_menu() break elif server_type == "3": clear() singleserver_mnu() break else: print("Invalid choice.") ##gre6 def run_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: subprocess.run( ["ping", "-c", "2", "fd1d:fc98:b73e:b481::2"], check=True, stdout=subprocess.DEVNULL, ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_v6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_v6.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) def display_kharej_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "fd1d:fc98:b73e:b481::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def add_cron_job(): file_path = "/etc/private.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) ##gre6 kharej def gre6_cronjob(): try: subprocess.run( "crontab -l | grep -v '/etc/gre6.sh' | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( "(crontab -l ; echo '@reboot /bin/bash /etc/gre6.sh') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ping_gre6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def gre6_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::1" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::1 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def create_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre6_kharej(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre6_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def gre6_kharejsec(): remote_ip = "fd1d:fc98:b73e:b481::2" # iran-ip local_ip = "fd1d:fc98:b73e:b481::1" # kharej ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() # espn_gre def kharej1_gre6_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre6_kharej() sleep(1) # sit kharej def kharej_gre6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre6_kharej() sleep(1) ##### IRAN gre6 def display_iran_ip(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = "fd1d:fc98:b73e:b481::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| {ip_addr} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_gre6_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def gre6_iran_tunnel(remote_ip, local_ip, num_additional_ips): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) created_ips = [] for i in range(2, num_additional_ips + 2): ip_address = f"2002:83{i}a::2" created_ips.append(ip_address) command = f"echo 'ip -6 addr add {ip_address}/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") for ip_address in created_ips: print("\033[92m" + f"| {ip_address} |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def gre6_iran_tunnelsec(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IPv6 Addresses:\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f"| 2002:831a::2 |" + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def iran_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre6_iran(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input( "\033[97mEnter the number of \033[92madditional IPs\033[97m for the \033[92mGRE6\033[97m tunnel: " ) ) gre6_iran_tunnel(remote_ip, local_ip, num_additional_ips) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gre6_iransec(): remote_ip = "fd1d:fc98:b73e:b481::1" # kharej ip local_ip = "fd1d:fc98:b73e:b481::2" # iran ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") gre6_iran_tunnelsec(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() ## gre6 erspan iran def iran1_gre6_menu(): global local_ip, remote_ip os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre6_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") # sit iran def iran_gre6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre6_iran() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") ## gre def gre_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_ip.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_ip.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_ip.service"]) subprocess.run(["systemctl", "start", "ping_ip.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_ip.service"]) def gre_ping_script(ip_address, max_pings, interval): file_path = "/etc/ping_ip.sh" if os.path.exists(file_path): os.remove(file_path) script_content = f"""#!/bin/bash ip_address="{ip_address}" max_pings={max_pings} interval={interval} while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open(file_path, "w") as file: file.write(script_content) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) def gre_iran(): remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) ip_address = remote_prefix max_pings = 3 interval = 2 gre_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) gre_service() def gre_kharej(): remote_ipv4 = input( "\033[93mEnter \033[92mIran IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) ip_address = remote_prefix max_pings = 3 interval = 2 gre_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) gre_service() ## kharej gre def server_ipv4(): command = "curl -s https://api.ipify.org" process = subprocess.run(command, shell=True, capture_output=True, text=True) if process.returncode != 0: print("Error retrieving server's IPv4 address.") return None ipv4 = process.stdout.strip() return ipv4 def kharej_gre_menu(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE \033[92mKharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mIRAN\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) file_path = "/etc/gre.sh" if os.path.exists(file_path): os.remove(file_path) display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────╮\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────╯\033[0m") ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("Enter the number of \033[92madditional IPv6\033[93m addresses: ") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") command = f"echo '/sbin/modprobe gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip tunnel add azumig mode gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add {ipv6}/16 dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) for i in range(2, num_additional_ips + 2): ip_address = f"{ipv6[:-1]}{i}/16" command = f"echo 'ip addr add {ip_address} dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) rt_command = ( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, ipv6_address ) ) with open("/etc/gre.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig mtu {mtu_value}\n" with open("/etc/gre.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) config_file_path = "/etc/gre.sh" subprocess.run( f"(crontab -l | grep -v -F '{file_path}') | crontab -", shell=True, check=True ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) display_checkmark("\033[92mGRE Configuration Completed!\033[0m") gre_kharej() # iran gre def iran_gre_menu(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE \033[92mIRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mKharej\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) file_path = "/etc/gre.sh" if os.path.exists(file_path): os.remove(file_path) display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────╮\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────╯\033[0m") ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_additional_ips = int( input("Enter the number of \033[92madditional IPv6\033[93m addresses: ") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") command = f"echo '/sbin/modprobe gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip tunnel add azumig mode gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip addr add {ipv6}/16 dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) for i in range(2, num_additional_ips + 2): ip_address = f"{ipv6[:-1]}{i}/16" command = f"echo 'ip addr add {ip_address} dev azumig' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) rt_command = ( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, ipv6_address ) ) with open("/etc/gre.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig mtu {mtu_value}\n" with open("/etc/gre.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) config_file_path = "/etc/gre.sh" subprocess.run( f"(crontab -l | grep -v -F '{file_path}') | crontab -", shell=True, check=True ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) display_checkmark("\033[92mGRE Configuration Completed!\033[0m") gre_iran() def clear_screen(): os.system("clear") def i6to4_menu(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(O,O)\033[0m") print("\033[92m( ) \033[93m6TO4 Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92m6to4 \033[0m") print("2. \033[93m6to4 Anycast\033[0m") print("3. \033[94mback to main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": i6to4_no() elif server_type == "2": i6to4_any() elif server_type == "3": clear_screen() main_menu() else: print("Invalid choice.") def add_6to4_job(): file_path = "/etc/6to4.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def i6to4_no(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m6TO4 \033[92m[Not Anycast]\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": i6to4_kharej() break elif server_type == "2": i6to4_iran() break elif server_type == "3": clear_screen() singleserver_mnu() break else: print("Invalid choice.") def ipv6_int(): interfaces = netifaces.interfaces() for iface in interfaces: if iface != "lo" and netifaces.AF_INET6 in netifaces.ifaddresses(iface): return iface return None def i6to4_kharej(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m6TO4 \033[92mKharej\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mIRAN\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring...\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) if prefix.endswith("::1"): gateway = prefix[:-3] + "::2" else: gateway = prefix[:-3] + "::1" with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote {} local {} ttl 255\n".format( remote_ip, local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via {} dev azumi6 metric 1\n".format( gateway ) ) f.write("ip -6 route add ::/0 dev azumi6\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) f.write( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, prefix ) ) else: print("Skipping changing the default route.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input("\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + num_ips): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") add_6to4_job() display_notification("\033[93mStarting 6to4...\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) remote_ipv4 = input( "\033[93mEnter \033[92mIran IPv4 address\033[93m [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = ( '''#!/bin/bash ip_address="''' + remote_prefix + """" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F"time=" "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done""" ) with open("/etc/ping_v6.sh", "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", "/etc/ping_v6.sh"]) service_content = """[Unit] Description=Ping Service After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target""" with open("/etc/systemd/system/ping_v6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") def i6to4_iran(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m6TO4 \033[92mIRAN\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mKharej\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring...\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPv4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) if prefix.endswith("::1"): gateway = prefix[:-3] + "::2" else: gateway = prefix[:-3] + "::1" with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote {} local {} ttl 255\n".format( remote_ip, local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via {} dev azumi6 metric 1\n".format( gateway ) ) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) f.write( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, prefix ) ) else: print("Skipping changing the default route.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input("\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + num_ips): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") add_6to4_job() display_notification("\033[93mStarting 6to4...\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4 address\033[93m [Ping Service]: \033[0m" ) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = ( '''#!/bin/bash ip_address="''' + remote_prefix + """" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F"time=" "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done""" ) with open("/etc/ping_v6.sh", "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", "/etc/ping_v6.sh"]) service_content = """[Unit] Description=Ping Service After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target""" with open("/etc/systemd/system/ping_v6.service", "w") as f: f.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") def clear(): subprocess.run(["clear"]) def i6to4_any(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m6to4 \033[92m[Anycast]\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": i6to4_any_kharej() elif server_type == "2": i6to4_any_iran() elif server_type == "3": clear() singleserver_mnu() else: print("Invalid choice.") def i6to4_any_kharej(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6to4 \033[92mKharej\033[93m Menu\033[92m[Anycast]\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your \033[92mKharej\033[93m IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mIRAN\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring...\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej IPv4\033[93m address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote any local {} ttl 255\n".format( local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev azumi6 metric 1\n" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = input( "\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + int(num_ips)): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") add_6to4_job() display_notification("\033[93mStarting 6to4...\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = """#!/bin/bash ip_address="{}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", "/etc/ping_v6.sh"]) with open("/etc/systemd/system/ping_v6.service", "w") as f: f.write("[Unit]\n") f.write("Description=Ping Service\n") f.write("After=network.target\n") f.write("\n") f.write("[Service]\n") f.write("ExecStart=/bin/bash /etc/ping_v6.sh\n") f.write("Restart=always\n") f.write("\n") f.write("[Install]\n") f.write("WantedBy=multi-user.target\n") subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") def i6to4_any_iran(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6to4 \033[92mIRAN\033[93m Menu\033[92m[Anycast]\033[0m" ) print('\033[92m"-"\033[93m════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your \033[92mIRAN\033[93m IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print("\033[97m For ping service, enter \033[92mKharej\033[97m IPV4 address") print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring...\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIran IPv4\033[93m address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote any local {} ttl 255\n".format( local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev azumi6 metric 1\n" ) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) f.write( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, prefix ) ) else: print("Skipping changing the default route.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input("\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + num_ips): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") add_6to4_job() display_notification("\033[93mStarting 6to4...\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) subprocess.run(["sleep", "1"]) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = """#!/bin/bash ip_address="{}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix ) with open("/etc/ping_v6.sh", "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", "/etc/ping_v6.sh"]) with open("/etc/systemd/system/ping_v6.service", "w") as f: f.write( """[Unit] Description=Ping Service After=network.target [Service] ExecStart=/bin/bash /etc/ping_v6.sh Restart=always [Install] WantedBy=multi-user.target """ ) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_v6.service"]) subprocess.run(["systemctl", "start", "ping_v6.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_v6.service"]) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") # test gre gen ipsec def gengre_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve \033[93m+ \033[96mGRE6 \033[93m+\033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1[Server Address]\033[0m") print("2. \033[93mMethod 2[Gre6 Address]\033[0m") print("3. \033[96mMethod 3[Geneve Address]\033[0m") print("4. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gengre_ipsec1() break elif server_type == "2": gengre_ipsec2() break elif server_type == "3": gengre_ipsec3() break elif server_type == "4": clear() main_menu() break else: print("Invalid choice.") # method 1 def gengre_ipsec1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve \033[93m+ \033[96mGRE6 \033[93m+ \033[92mIPV4 \033[93m Menu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej_ipgen_menu() break elif server_type == "2": iran_ipgen_menu() break elif server_type == "3": clear() main_menu() break else: print("Invalid choice.") def kharej_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgen_ipvers() def ipgen_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgen_ipk_version1() break elif server_type == "2": ipgen_ipk_version2() break else: print("Invalid choice.") def ipgen_ipk_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("66.200.1.1") ufw("66.200.2.1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def ipgen_ipk_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("2001:db8::1") ufw("2001:db8::2") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgen2_ipvers() def ipgen2_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgen_ipi_version1() break elif server_type == "2": ipgen_ipi_version2() break else: print("Invalid choice.") def ipgen_ipi_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("66.200.1.1") ufw("66.200.2.1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ipgen_ipi_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("2001:db8::1") ufw("2001:db8::2") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # method 2 def gengre_ipsec2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve \033[93m+ \033[96mGRE6 \033[93m+ \033[92mIPV4 \033[93m M2\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejm2_ipgen_menu() break elif server_type == "2": iranm2_ipgen_menu() break elif server_type == "3": clear() gengre_ipsec() else: print("Invalid choice.") def kharejm2_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgenm2_ipvers() def ipgenm2_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgenm2_ipk_version1() break elif server_type == "2": ipgenm2_ipk_version2() break else: print("Invalid choice.") # for method 2 geneve def configm2_strongsw_simkh1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:832a::1/64 leftid=2002:832a::1 right=2002:832a::2 rightsubnet=2002:832a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:832a::2 2002:832a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## def ipgenm2_ipk_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("66.200.1.1") ufw("66.200.2.1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simkh1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def ipgenm2_ipk_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("2001:db8::1") ufw("2001:db8::2") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simkh1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # for method 2 geneve def configm2_strongsw_simih1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:832a::2/64 leftid=2002:832a::2 right=2002:832a::1 rightsubnet=2002:832a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:832a::1 2002:832a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## def iranm2_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgen2m2_ipvers() def ipgen2m2_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgenm2_ipi_version1() break elif server_type == "2": ipgenm2_ipi_version2() break else: print("Invalid choice.") def ipgenm2_ipi_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("66.200.2.1") ufw("66.200.1.1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simih1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ipgenm2_ipi_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2002:831::1") ufw("2002:831::2") ufw("2001:db8::2") ufw("2001:db8::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simih1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # method 3 def gengre_ipsec3(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[92mGeneve \033[93m+ \033[96mGRE6 \033[93m+ \033[92mIPV4 \033[93m M3\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejm3_ipgen_menu() break elif server_type == "2": iranm3_ipgen_menu() break elif server_type == "3": clear() gengre_ipsec() else: print("Invalid choice.") def kharejm3_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgenm3_ipvers() def ipgenm3_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgenm3_ipk_version1() break elif server_type == "2": ipgenm3_ipk_version2() break else: print("Invalid choice.") # for method 3 geneve def configm31_strongsw_simk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.1.1/32 leftid=66.200.1.1 right=66.200.2.1 rightsubnet=66.200.2.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.2.1 66.200.1.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## def configm32_strongsw_simk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::1/64 leftid=2001:db8::1 right=2001:db8::2 rightsubnet=2001:db8::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::2 2001:db8::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## ## icmp test def icmp_erspan4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmpV4 + Erspan + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + IPsec Method 1 [Server Address] \033[0m") print("2. \033[96mErspan + IPsec Method 2 [Erspan Address] \033[0m") print("3. \033[94mBack to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_ipsec1() break elif server_type == "2": icmp_ipsec2() break elif server_type == "3": os.system("clear") main_menu() break else: print("Invalid choice.") # icmp erspan ipv4 and ipv6 server address def icmp_ipsec1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmpV4 + Erspan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_kharej_espnV4() break elif server_type == "2": icmp_iran_espnV4() break elif server_type == "3": os.system("clear") icmp_erspan4() break else: print("Invalid choice.") def install_icmp4(): display_notification("\033[93mInstalling \033[92mIcmpV4\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() ipv4_forward_status = subprocess.run( ["sysctl", "-n", "net.ipv4.ip_forward"], capture_output=True, text=True ) if int(ipv4_forward_status.stdout) != 1: subprocess.run(["sysctl", "net.ipv4.ip_forward=1"]) subprocess.run( ["sudo", "apt", "install", "-y", "git"], capture_output=True, text=True ) if os.path.exists("/root/icmpv4"): shutil.rmtree("/root/icmpv4") clone_command = "git clone https://github.com/miyugundam/icmp.git icmpv4" clone_result = os.system(clone_command) if clone_result != 0: print("Error: Failed to clone Repo.") return if os.path.exists("/root/icmpv4"): os.chdir("/root/icmpv4") subprocess.run( ["sudo", "apt", "install", "-y", "net-tools"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "make"], capture_output=True, text=True ) subprocess.run( ["sudo", "apt-get", "install", "-y", "libssl-dev"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "g++"], capture_output=True, text=True ) subprocess.run(["make"], capture_output=True, text=True) os.chdir("..") else: display_error("\033[91micmp folder not found.\033[0m") pass def icmp41_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "70.0.0.2"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def start_ic4_kharej(): display_notification("\033[93mConfiguring \033[92mKharej\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated ICMP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def icmp42_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "70.0.0.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def start_ic4_iran(): display_notification("\033[93mConfiguring \033[92mIRAN \033[93m...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/icmpv4") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {remote_ip} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated ICMP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def icmp_kharej_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") icmpv4_spn_kharej() def icmpv4_spn_kharej(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp4_simpk1() break elif server_type == "2": icmp4_simk2() break else: print("Invalid choice.") def icmp4_simpk1(): start_ic4_kharej() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.1", "remote", "70.0.0.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.1 remote 70.0.0.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def icmp4_simk2(): start_ic4_kharej() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.1", "remote", "70.0.0.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.1 remote 70.0.0.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def icmp_iran_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_icmp4_iran() def spn_icmp4_iran(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp4_simpi1() break elif server_type == "2": icmp4_simpi2() break else: print("Invalid choice.") def icmp4_simpi1(): start_ic4_iran() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.2", "remote", "70.0.0.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.2 remote 70.0.0.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def icmp4_simpi2(): start_ic4_iran() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.2", "remote", "70.0.0.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.2 remote 70.0.0.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def up_up(): ulimit_setting = "ulimit -n 65535" bashrc_path = os.path.expanduser("~/.bashrc") with open(bashrc_path, "r") as f: existing_bashrc = f.read() if ulimit_setting not in existing_bashrc: with open(bashrc_path, "a") as f: f.write("\n") f.write(ulimit_setting) f.write("\n") sysctl_conf_path = "/etc/sysctl.conf" sysctl_params = [ "net.core.rmem_max=26214400", "net.core.rmem_default=26214400", "net.core.wmem_max=26214400", "net.core.wmem_default=26214400", "net.core.netdev_max_backlog=2048", ] with open(sysctl_conf_path, "r") as f: existing_sysctl_conf = f.read() params_to_add = [] for param in sysctl_params: if param not in existing_sysctl_conf: params_to_add.append(param) if params_to_add: with open(sysctl_conf_path, "a") as f: f.write("\n") f.write("\n".join(params_to_add)) f.write("\n") try: subprocess.run( ["sudo", "sysctl", "-p"], stderr=subprocess.DEVNULL, check=True ) display_checkmark("\033[92mIt is Done!\033[0m") except subprocess.CalledProcessError: print("\033[91mAn error occurred while setting it up.\033[0m") else: display_checkmark("\033[92mIt was already Done.\033[0m") # icmpv4 erspan erspan address def icmp_ipsec2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmpV4 + Erspan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmpm2_kharej_espnV4() break elif server_type == "2": icmpm2_iran_espnV4() break elif server_type == "3": os.system("clear") icmp_erspan4() break else: print("Invalid choice.") # prequisite def startm2_ic4_kharej1(): display_notification("\033[93mConfiguring \033[92mKharej\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp4k1(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") def startm2_ic4_kharej2(): display_notification("\033[93mConfiguring \033[92mKharej\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp4k2(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") def startm2_ic4_iran1(): display_notification("\033[93mConfiguring \033[92mIRAN \033[93m...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp4i1(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/icmpv4") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {remote_ip} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp2_ping() def startm2_ic4_iran2(): display_notification("\033[93mConfiguring \033[92mIRAN \033[93m...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp4i2(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/icmpv4") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {remote_ip} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp2_ping() def icmpm2_kharej_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") icmpv4m2_spn_kharej() def icmpv4m2_spn_kharej(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp4m2_simpk1() break elif server_type == "2": icmp4m2_simk2() break else: print("Invalid choice.") def icmp4m2_simpk1(): startm2_ic4_kharej1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.1", "remote", "70.0.0.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.1 remote 70.0.0.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def icmp4m2_simk2(): startm2_ic4_kharej2() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.1", "remote", "70.0.0.2", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.1 remote 70.0.0.2 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def icmpm2_iran_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spnm2_icmp4_iran() def spnm2_icmp4_iran(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp4m2_simpi1() break elif server_type == "2": icmp4m2_simpi2() break else: print("Invalid choice.") def icmp4m2_simpi1(): startm2_ic4_iran1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.2", "remote", "70.0.0.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.2 remote 70.0.0.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def icmp4m2_simpi2(): startm2_ic4_iran2() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "70.0.0.2", "remote", "70.0.0.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 70.0.0.2 remote 70.0.0.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def config_strongsw_icmp4k1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.1.1/32 leftid=66.200.1.1 right=66.200.2.1 rightsubnet=66.200.2.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.2.1 66.200.1.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_icmp4k2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::1/64 leftid=2001:db8::1 right=2001:db8::2 rightsubnet=2001:db8::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::2 2001:db8::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_icmp4i1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.2.1/32 leftid=66.200.2.1 right=66.200.1.1 rightsubnet=66.200.1.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.1.1 66.200.2.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_icmp4i2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::2/64 leftid=2001:db8::2 right=2001:db8::1 rightsubnet=2001:db8::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::1 2001:db8::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## def ipgenm3_ipk_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm31_strongsw_simk1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def ipgenm3_ipk_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw("2001:db8::2") ufw("fd1d:fc98:b73e:b481::2") ufw("2002:831a::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") kharej1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm32_strongsw_simk1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") # for method 3 geneve def configm31_strongsw_simi1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.2.1/32 leftid=66.200.2.1 right=66.200.1.1 rightsubnet=66.200.1.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.1.1 66.200.2.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # for method 3 geneve def configm32_strongsw_simi1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::2/64 leftid=2001:db8::2 right=2001:db8::1 rightsubnet=2001:db8::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::1 2001:db8::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) ## def iranm3_ipgen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ipgen2m3_ipvers() def ipgen2m3_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipgenm3_ipi_version1() break elif server_type == "2": ipgenm3_ipi_version2() break else: print("Invalid choice.") def ipgenm3_ipi_version1(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm31_strongsw_simi1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ipgenm3_ipi_version2(): global local_ip, remote_ip print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw("2001:db8::1") ufw("2002:831a::1") ufw("fd1d:fc98:b73e:b481::1") print("\033[93m─────────────────────────────────────────────────────────\033[0m") iran1_gre6_menu() print("\033[93m─────────────────────────────────────────────────────────\033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm32_strongsw_simi1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::2/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## hans icmp test def icmp_erspan5(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans + Erspan + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan + IPsec Method 1 [Server Address] \033[0m") print("2. \033[96mErspan + IPsec Method 2 [Erspan Address] \033[0m") print("3. \033[94mBack to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz_ipsec1() break elif server_type == "2": hanz_ipsec2() break elif server_type == "3": os.system("clear") main_menu() break else: print("Invalid choice.") # hans erspan ipv4 and ipv6 server address def hanz_ipsec1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans + Erspan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz_kharej_espnV4() break elif server_type == "2": hanz_iran_espnV4() break elif server_type == "3": os.system("clear") icmp_erspan5() break else: print("Invalid choice.") def hanss_install_menu(): display_notification("\033[93mInstalling \033[92mHans\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() ipv4_forward_status = subprocess.run( ["sysctl", "-n", "net.ipv4.ip_forward"], capture_output=True, text=True ) if int(ipv4_forward_status.stdout) != 1: subprocess.run(["sysctl", "net.ipv4.ip_forward=1"]) subprocess.run( [ "wget", "https://sourceforge.net/projects/hanstunnel/files/source/hans-1.1.tar.gz", ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) subprocess.run( ["tar", "-xzf", "hans-1.1.tar.gz"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) os.chdir("/root/hans-1.1") subprocess.run(["apt", "install", "-y", "make"], check=True) subprocess.run(["apt", "install", "-y", "g++"], check=True) subprocess.run(["make"], check=True) display_checkmark("\033[92mHans installed successfully!\033[0m") os.remove("/root/hans-1.1.tar.gz") pass def icmp3_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.100"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def hns_icmp_kharej1(): display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) hans_directory = "/root/hans-1.1" os.chdir(hans_directory) os.system(f"./hans -s 80.1.2.0 -p azumi86chwan -d icmp") hans_kharej_command = f"{hans_directory}/hans -s 80.1.2.0 -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_kharej_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_kharej_command}\n") subprocess.run( ["chmod", "700", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def icmp4_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def hns_icmp_iran1(): display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/hans-1.1") os.system(f"./hans -c {remote_ip} -p azumi86chwan -d icmp") subprocess.call(["rm", "-f", "/etc/cron.d/hans"]) hans_command = f"/root/hans-1.1/hans -c {remote_ip} -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_command}\n") icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.100\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def hanz_kharej_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") hanz_spn_kharej() def hanz_spn_kharej(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz_simpk1() break elif server_type == "2": hanz_simk2() break else: print("Invalid choice.") def hanz_simpk1(): hns_icmp_kharej1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.1", "remote", "80.1.2.100", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.1 remote 80.1.2.100 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def hanz_simk2(): hns_icmp_kharej1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.1", "remote", "80.1.2.100", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.1 remote 80.1.2.100 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def hanz_iran_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_hanz_iran() def spn_hanz_iran(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz_simpi1() break elif server_type == "2": hanz_simpi2() break else: print("Invalid choice.") def hanz_simpi1(): hns_icmp_iran1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.100", "remote", "80.1.2.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.100 remote 80.1.2.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def hanz_simpi2(): hns_icmp_iran1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.100", "remote", "80.1.2.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.100 remote 80.1.2.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # erspan address def config_strongsw_hanzk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.1.1/32 leftid=66.200.1.1 right=66.200.2.1 rightsubnet=66.200.2.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.2.1 66.200.1.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_hanzk2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::1/64 leftid=2001:db8::1 right=2001:db8::2 rightsubnet=2001:db8::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::2 2001:db8::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def hanz_ipsec2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans + Erspan Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz2_kharej_espnV4() break elif server_type == "2": hanz2_iran_espnV4() break elif server_type == "3": os.system("clear") icmp_erspan5() break else: print("Invalid choice.") def hanss_install_menu(): display_notification("\033[93mInstalling \033[92mHans\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() ipv4_forward_status = subprocess.run( ["sysctl", "-n", "net.ipv4.ip_forward"], capture_output=True, text=True ) if int(ipv4_forward_status.stdout) != 1: subprocess.run(["sysctl", "net.ipv4.ip_forward=1"]) subprocess.run( [ "wget", "https://sourceforge.net/projects/hanstunnel/files/source/hans-1.1.tar.gz", ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) subprocess.run( ["tar", "-xzf", "hans-1.1.tar.gz"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) os.chdir("/root/hans-1.1") subprocess.run(["apt", "install", "-y", "make"], check=True) subprocess.run(["apt", "install", "-y", "g++"], check=True) subprocess.run(["make"], check=True) display_checkmark("\033[92mHans installed successfully!\033[0m") os.remove("/root/hans-1.1.tar.gz") pass def icmp3_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.100"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def hns2_icmp_kharej1(): display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_hanzk1(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) hans_directory = "/root/hans-1.1" os.chdir(hans_directory) os.system(f"./hans -s 80.1.2.0 -p azumi86chwan -d icmp") hans_kharej_command = f"{hans_directory}/hans -s 80.1.2.0 -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_kharej_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_kharej_command}\n") subprocess.run( ["chmod", "700", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp3_ping() def hns3_icmp_kharej1(): display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_hanzk2(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) hans_directory = "/root/hans-1.1" os.chdir(hans_directory) os.system(f"./hans -s 80.1.2.0 -p azumi86chwan -d icmp") hans_kharej_command = f"{hans_directory}/hans -s 80.1.2.0 -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_kharej_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_kharej_command}\n") subprocess.run( ["chmod", "700", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp3_ping() def icmp4_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def config_strongsw_hanzi1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.2.1/32 leftid=66.200.2.1 right=66.200.1.1 rightsubnet=66.200.1.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.1.1 66.200.2.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_hanzi2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::2/64 leftid=2001:db8::2 right=2001:db8::1 rightsubnet=2001:db8::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::2 2001:db8::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def hns2_icmp_iran1(): display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_hanzi1(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/hans-1.1") os.system(f"./hans -c {remote_ip} -p azumi86chwan -d icmp") subprocess.call(["rm", "-f", "/etc/cron.d/hans"]) hans_command = f"/root/hans-1.1/hans -c {remote_ip} -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_command}\n") icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp4_ping() def hns3_icmp_iran1(): display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_hanzi2(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/hans-1.1") os.system(f"./hans -c {remote_ip} -p azumi86chwan -d icmp") subprocess.call(["rm", "-f", "/etc/cron.d/hans"]) hans_command = f"/root/hans-1.1/hans -c {remote_ip} -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_command}\n") icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp4_ping() def hanz2_kharej_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") hanz2_spn_kharej() def hanz2_spn_kharej(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz2_simpk1() break elif server_type == "2": hanz2_simk2() break else: print("Invalid choice.") def hanz2_simpk1(): hns2_icmp_kharej1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.1", "remote", "80.1.2.100", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.1 remote 80.1.2.100 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.2.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def hanz2_simk2(): hns3_icmp_kharej1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.1", "remote", "80.1.2.100", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.1 remote 80.1.2.100 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def hanz2_iran_espnV4(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") spn_hanz2_iran() def spn_hanz2_iran(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Erspan IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hanz2_simpi1() break elif server_type == "2": hanz2_simpi2() break else: print("Invalid choice.") def hanz2_simpi1(): hns2_icmp_iran1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.100", "remote", "80.1.2.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.100 remote 80.1.2.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumiespn\n") f.write("sudo ip route add 66.200.1.1/32 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def hanz2_simpi2(): hns3_icmp_iran1() subprocess.run( [ "sudo", "ip", "link", "add", "dev", "azumiespn", "type", "erspan", "local", "80.1.2.100", "remote", "80.1.2.1", "seq", "key", "100", "erspan_ver", "1", "erspan", "1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumiespn", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumiespn"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add dev azumiespn type erspan local 80.1.2.100 remote 80.1.2.1 seq key 100 erspan_ver 1 erspan 1\n" ) f.write("sudo ip link set azumiespn up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumiespn\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Erspan]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumiespn mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## # test gen ipsec def gen4_ipsec_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve \033[93m+ IPV4 + \033[92mIPsec \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve + IPsec\033[0m") print("2. \033[93mGeneve + GRE6 + IPsec\033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen4_ipsec() break elif server_type == "2": gengre_ipsec() break elif server_type == "3": choose_reset() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def gen4_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve \033[93m+ IPV4 + \033[92mIPsec \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1[Server Address]\033[0m") print("2. \033[93mMethod 2[Geneve Address]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen41_ipsec() break elif server_type == "2": gen42_ipsec() break elif server_type == "3": clear() gen4_ipsec_mnu() break else: print("Invalid choice.") # method1 gen41 def gen41_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve \033[93m+ IPV4 + \033[92mIPsec M[1] \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_ipseck() break elif server_type == "2": gen_ipseci() break elif server_type == "3": clear() gen4_ipsec() break else: print("Invalid choice.") def gen_ipseck(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") gen_simple1() def gen_simple1(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_simpk1() break elif server_type == "2": gen_simpk2() break else: print("Invalid choice.") def config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def gen_simpk1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") ufw(local_ip) ufw(remote_ip) ufw("66.200.1.1") ufw("66.200.2.1") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen_simpk2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") ufw(local_ip) ufw(remote_ip) ufw("2001:db8::1") ufw("2001:db8::2") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simk2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen_ipseci(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") gen_simple2() def gen_simple2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_simpi1() break elif server_type == "2": gen_simpi2() break else: print("Invalid choice.") def gen_simpi1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") ufw(local_ip) ufw(remote_ip) ufw("66.200.2.1") ufw("66.200.1.1") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi1(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def gen_simpi2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") ufw(local_ip) ufw(remote_ip) ufw("2001:db8::1") ufw("2001:db8::2") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_simi2(local_ip, local_subnet, remote_ip, remote_subnet, psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") # method 2 gen42 def gen42_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve \033[93m+ IPV4 + \033[92mIPsec M[2] \033[0m") print('\033[92m "-"\033[93m══════════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genm2_ipseck() break elif server_type == "2": genm2_ipseci() break elif server_type == "3": clear() gen4_ipsec() break else: print("Invalid choice.") def genm2_ipseck(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") genm2_simple1() def genm2_simple1(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genm2_simpk1() break elif server_type == "2": genm2_simpk2() break else: print("Invalid choice.") def configm2_strongsw_simk1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.1.1/32 leftid=66.200.1.1 right=66.200.2.1 rightsubnet=66.200.2.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.2.1 66.200.1.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def configm2_strongsw_simk2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::1/64 leftid=2001:db8::1 right=2001:db8::2 rightsubnet=2001:db8::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::2 2001:db8::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def configm2_strongsw_simi1(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=66.200.2.1/32 leftid=66.200.2.1 right=66.200.1.1 rightsubnet=66.200.1.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'66.200.1.1 66.200.2.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def configm2_strongsw_simi2(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2001:db8::2/64 leftid=2001:db8::2 right=2001:db8::1 rightsubnet=2001:db8::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2001:db8::1 2001:db8::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def genm2_simpk1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.1.1") ufw("66.200.2.1") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simk1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def genm2_simpk2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db8::1") ufw("2001:db8::2") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simk2(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::1/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add 2001:db8::1/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan3_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def genm2_ipseci(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIRAN server \033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring IRAN server...\033[0m") if os.path.isfile("/etc/spn.sh"): os.remove("/etc/spn.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") genm2_simple2() def genm2_simple2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genm2_simpi1() break elif server_type == "2": genm2_simpi2() break else: print("Invalid choice.") def genm2_simpi1(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.2.1") ufw("66.200.1.1") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simi1(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan2_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def ipsecs_uninstall(): delete_cron1() delete_cron2() remove_private() remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Erspan + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True, ) devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("sudo ip link delete azumiespn > /dev/null", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) ##ipip + ipsec def ipip__ipsec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIP6IP6 IPSEC Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": ipip6_reset_rmvmnussingle() kharej_ipip6sec_menu() break elif server_type == "2": ipip6_reset_rmvmnussingle() iran_ipip6sec_menu() break elif server_type == "3": choose_reset() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def azumi_ip6ip6_k(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:0db8:1234:a220::1/64 leftid=2002:0db8:1234:a220::1 right=2002:0db8:1234:a220::2 rightsubnet=2002:0db8:1234:a220::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a220::2 2002:0db8:1234:a220::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_ip6ip6_ir(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:0db8:1234:a220::2/64 leftid=2002:0db8:1234:a220::2 right=2002:0db8:1234:a220::1 rightsubnet=2002:0db8:1234:a220::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:0db8:1234:a220::1 2002:0db8:1234:a220::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def kharej_ipip6sec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mConfiguring IPIP6 \033[92mKharej\033[93m server\033[0m" ) print('\033[92m "-"\033[93m═════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_ip6ip6_k(psk) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip_kharejsec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") def iran_ipip6sec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring IPIP6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_ip6ip6_ir(psk) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi\n") print("\033[93m─────────────────────────────────────────────────────────\033[0m") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") ipip_iransec() sleep(1) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ##Private ip + ipsec def private_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mPrivate IP +IPSec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": private_reset_rmvmnusingle() kharej_private_ipsec() break elif server_type == "2": private_reset_rmvmnusingle() iran_private_ipsec() break elif server_type == "3": choose_reset() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def azumi_private_k(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831b::1/64 leftid=2002:831b::1 right=2002:831b::2 rightsubnet=2002:831b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831b::2 2002:831b::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_private_ir(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831b::2/64 leftid=2002:831b::2 right=2002:831b::1 rightsubnet=2002:831b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831b::1 2002:831b::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def kharej_private_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Kharej server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m There is also a cronjob and a ping service that automatically installs" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_private_k(psk) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "-6", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::1/64 dev azumi\n") f.write("ip -6 route add 2002:831b::2/64 dev azumi\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::1\n".format( interface ) with open("/etc/private.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (Kharej):\033[0m") ip_addr = f"2002:831b::1" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def iran_private_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring Iran server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m There is also a cronjob and a ping service that automatically installs" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_private_ir(psk) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "-6", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "route", "add", "2002:831b::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::2/64 dev azumi\n") f.write("ip -6 route add 2002:831b::1/64 dev azumi\n") answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831b::2\n".format( interface ) with open("/etc/private.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") add_cron_job() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping_iran() sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated Private IP Addresses (IRAN):\033[0m") ip_addr = f"2002:831b::2" print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + f" {ip_addr} " + "\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() def genm2_simpi2(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("2001:db8::2") ufw("2001:db8::1") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") configm2_strongsw_simi2(psk) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "2001:db8::2/64", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/spn.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 2001:db8::2/64 dev azumigen\n") f.write("systemctl restart strongswan-starter\n") f.write("systemctl restart strongswan\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/spn.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") espan_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") espan4_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 2001:db8::2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="2001:db8::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_espan.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_espan.sh", 0o755) ping_gengre_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def gre6sec_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGRE6 + IPSec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN \033[0m") print("3. \033[93mIPsec Reset Timer \033[0m") print("0. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gre6_reset_rmvmnusingle() kharej_gre6_sec() break elif server_type == "2": gre6_reset_rmvmnusingle() iran_gre6_sec() break elif server_type == "3": choose_reset() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") def azumi_private_k(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831b::1/64 leftid=2002:831b::1 right=2002:831b::2 rightsubnet=2002:831b::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831b::2 2002:831b::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_private_ir(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831b::2/64 leftid=2002:831b::2 right=2002:831b::1 rightsubnet=2002:831b::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831b::1 2002:831b::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_gre6_k(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831a::1/64 leftid=2002:831a::1 right=2002:831a::2 rightsubnet=2002:831a::2/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::2 2002:831a::1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def azumi_gre6_ir(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=2002:831a::2/64 leftid=2002:831a::2 right=2002:831a::1 rightsubnet=2002:831a::1/64 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'2002:831a::1 2002:831a::2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) # sit kharej def kharej_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mKharej\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Kharej server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gre6_k(psk) initial_ip = "fd1d:fc98:b73e:b481::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::2/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::1/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::2/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") gre6_kharejsec() sleep(1) # sit iran def iran_gre6_sec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mConfiguring GRE6 \033[92mIran\033[93m server\033[0m") print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print( "\033[93m╭───────────────────────────────────────────────────────────────────────────────────────╮" ) print( "\033[92m Please make sure to remove any private IPs that you have created before proceeding" ) print( "\033[93m Enter your Kharej and Iran IPV4 address, it will automatically configure your server" ) print( "\033[96m If you need additional IP address, you can enter the desired number" ) print( "\033[93m╰───────────────────────────────────────────────────────────────────────────────────────╯\033[0m" ) display_notification( "\033[93mAdding private IP addresses for Iran server...\033[0m" ) if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") azumi_gre6_ir(psk) initial_ip = "fd1d:fc98:b73e:b481::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) subprocess.run( ["ip", "-6", "route", "add", "fd1d:fc98:b73e:b481::1/64", "dev", "azumi"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add fd1d:fc98:b73e:b481::2/64 dev azumi\n") f.write("ip -6 route add fd1d:fc98:b73e:b481::1/64 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_pingg() sleep(1) script_content1 = """#!/bin/bash ip_address="fd1d:fc98:b73e:b481::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gre6_iransec() sleep(1) display_checkmark("\033[92mGRE6 Configuration Completed!\033[0m") def remove_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[91mUninstall\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mUninstall IP6IP6\033[0m") print("2. \033[96mUninstall IP6IP6 + IPSec\033[0m") print("3. \033[93mUninstall 6to4\033[0m") print("4. \033[92mUninstall 6to4 \033[96manycast\033[0m") print("5. \033[96mUninstall Gre\033[0m") print("42.\033[97mUninstall erspan ip6ip6 [test]\033[0m") print("6. \033[92mUninstall Gre6\033[0m") print("7. \033[93mUninstall Gre6 + IPSec\033[0m") print("8. \033[97mUninstall Gre6tap\033[0m") print("9. \033[96mUninstall Gre6tap + IPSec\033[0m") print("10. \033[93mUninstall Private IP\033[0m") print("11. \033[92mUninstall Private IP + IPSec\033[0m") print("12. \033[96mUninstall Extra Native IP\033[0m") print("13. \033[92mUninstall Geneve | IPsec\033[0m") print("14. \033[93mUninstall Erspan\033[0m") print("15.\033[96mUninstall icmp + ipsec & erspan & hans\033[0m") print("16.\033[93mUninstall Vxlan\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_ipip6() break elif server_type == "2": remove_ipip6sec() break elif server_type == "3": remove_6to4() break elif server_type == "4": remove_6to4() break elif server_type == "5": remove_gre() break elif server_type == "42": gre6test_uninstall() break elif server_type == "15": icmp_uninstall() break elif server_type == "16": vxlan_uninstall() break elif server_type == "6": remove_gre6() break elif server_type == "7": remove_gre6sec() break elif server_type == "10": remove_private() break elif server_type == "11": remove_privatesec() break elif server_type == "12": extra_uninstall() break elif server_type == "13": genx_ip() break elif server_type == "14": erspan_remove() break elif server_type == "8": gre6tap_remove() break elif server_type == "9": gre6tapsec_remove() break elif server_type == "0": clear() singleserver_mnu() break else: print("Invalid choice.") # erspan remove def erspan_remove(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mErspan\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mErspan \033[0m") print("2. \033[93mErspan + Native \033[0m") print("3. \033[96mErspan + Gre6 \033[0m") print("4. \033[92mErspan + Gre6tap \033[0m") print("5. \033[97mErspan + IPsec Tunnels \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": espn_uninstall() break elif server_type == "2": espn_uninstall() break elif server_type == "3": gre6espn_uninstall() break elif server_type == "4": gre6tapespn_uninstall() break elif server_type == "5": ipsecs_uninstall() break elif server_type == "0": clear() remove_menu() break else: print("Invalid choice.") ## def ipsecs_uninstall(): delete_cron1() delete_cron2() remove_private() remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Erspan + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True, ) devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("sudo ip link delete azumiespn > /dev/null", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def ipsecs_uninstall_private(): delete_cron1() delete_cron2() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIpsec \033[93m+ Tunnels\033[0m") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True ) devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run("systemctl disable strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run("systemctl daemon-reload", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration try: while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # gen ipsec def ipsecs_uninstall_gen(): delete_cron1() delete_cron2() remove_private() remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Gen + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True, ) devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # ip6ip6 ipsec def ipsecs_uninstall_ipip(): delete_cron1() delete_cron2() remove_private() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving IP6IP6 + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) # test icmp def config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet={local_subnet} leftid={local_ip} right={remote_ip} rightsubnet={remote_subnet} ike=aes256-sha256-modp3072! esp=aes128gcm16-modp3072! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'{remote_ip} {local_ip} : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_kharej_icmp(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=70.0.0.1/32 leftid=70.0.0.1 right=70.0.0.2 rightsubnet=70.0.0.2/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'70.0.0.2 70.0.0.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_iran_icmp(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=70.0.0.2/32 leftid=70.0.0.2 right=70.0.0.1 rightsubnet=70.0.0.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'70.0.0.1 70.0.0.2 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def icmp_ip_mnu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmp + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIcmp V4 \033[0m") print("2. \033[96mIcmp V6[Not yet added] \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_ipgov4_menu() break elif server_type == "2": icmp_ipgov6_menu() break elif server_type == "3": os.system("clear") singleserver_mnu() break else: print("Invalid choice.") def icmp_ipgov4_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmpV4 + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIcmp + IPsec\033[0m") print("2. \033[96mHans + Erspan + IPsec \033[0m") print("3. \033[93mICMP + Erspan + IPsec \033[0m") print("4. \033[97mIPsec Reset Timer \033[0m") print("0. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_ipsec() break elif server_type == "2": icmp_erspan4() break elif server_type == "3": icmp_erspan5() break elif server_type == "4": choose_reset() break elif server_type == "0": os.system("clear") icmp_ip_mnu() break else: print("Invalid choice.") def icmp_ipsec(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmp + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIcmp Method 1 \033[0m") print("2. \033[96mHans Method 2 \033[0m") print("3. \033[94mBack to the main menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_v4_menu() break elif server_type == "2": hans_v4_menu() break elif server_type == "3": os.system("clear") main_menu() break else: print("Invalid choice.") def icmp_v4_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmp + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1[Server Address] \033[0m") print("2. \033[96mMethod 2[Icmp Address] \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": icmp_socat1_menu() break elif server_type == "2": icmp_socat2_menu() break elif server_type == "3": os.system("clear") icmp_ipsec() break else: print("Invalid choice.") # server address def icmp_socat1_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmptunnel Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": start_ic_kharej3() break elif server_type == "2": start_ic_iran3() break elif server_type == "3": os.system("clear") icmp_v4_menu() break else: print("Invalid choice.") def install_icmp(): display_notification("\033[93mInstalling \033[92mIcmptunnel\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() ipv4_forward_status = subprocess.run( ["sysctl", "-n", "net.ipv4.ip_forward"], capture_output=True, text=True ) if int(ipv4_forward_status.stdout) != 1: subprocess.run(["sysctl", "net.ipv4.ip_forward=1"]) subprocess.run( ["sudo", "apt", "install", "-y", "git"], capture_output=True, text=True ) if os.path.exists("/root/icmpv4"): shutil.rmtree("/root/icmpv4") clone_command = "git clone https://github.com/miyugundam/icmp.git icmpv4" clone_result = os.system(clone_command) if clone_result != 0: print("Error: Failed to clone Repo.") return if os.path.exists("/root/icmpv4"): os.chdir("/root/icmpv4") subprocess.run( ["sudo", "apt", "install", "-y", "net-tools"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "make"], capture_output=True, text=True ) subprocess.run( ["sudo", "apt-get", "install", "-y", "libssl-dev"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "g++"], capture_output=True, text=True ) subprocess.run(["make"], capture_output=True, text=True) os.chdir("..") else: display_error("\033[91micmp folder not found.\033[0m") pass def icmp1_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "70.0.0.2"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def icmp2_cron_job(): file_path = "/etc/hans.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def icmp_cron_job(): file_path = "/etc/icmp.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def start_ic_kharej3(): display_notification("\033[93mConfiguring \033[92mKharej\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def icmp2_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "70.0.0.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def start_ic_iran3(): display_notification("\033[93mConfiguring \033[92mIRAN \033[93m...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/icmpv4") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {remote_ip} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # icmp address def icmp_socat2_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmptunnel Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": start_ic2_kharej() break elif server_type == "2": start_ic2_iran() break elif server_type == "3": os.system("clear") icmp_v4_menu() break else: print("Invalid choice.") def start_ic2_kharej(): display_notification("\033[93mConfiguring \033[92mKharej\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_kharej_icmp(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp1_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def start_ic2_iran(): display_notification("\033[93mConfiguring \033[92mIRAN \033[93m...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_iran_icmp(psk) if not os.path.exists("/root/icmpv4"): install_icmp() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/icmpv4") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {remote_ip} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") icmp_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp2_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 70.0.0.2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def hans_v4_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans + IPsec Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1[Server Address] \033[0m") print("2. \033[96mMethod 2[Icmp Address] \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hans_V41() break elif server_type == "2": hans_V42() break elif server_type == "3": os.system("clear") icmp_ipsec() break else: print("Invalid choice.") # server address def hans_V41(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hns_icmp_kharej1() break elif server_type == "2": hns_icmp_iran1() break elif server_type == "3": os.system("clear") hans_V41() break else: print("Invalid choice.") def hanss_install_menu(): display_notification("\033[93mInstalling \033[92mHans\033[93m ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() ipv4_forward_status = subprocess.run( ["sysctl", "-n", "net.ipv4.ip_forward"], capture_output=True, text=True ) if int(ipv4_forward_status.stdout) != 1: subprocess.run(["sysctl", "net.ipv4.ip_forward=1"]) subprocess.run( [ "wget", "https://sourceforge.net/projects/hanstunnel/files/source/hans-1.1.tar.gz", ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) subprocess.run( ["tar", "-xzf", "hans-1.1.tar.gz"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) os.chdir("/root/hans-1.1") subprocess.run(["apt", "install", "-y", "make"], check=True) subprocess.run(["apt", "install", "-y", "g++"], check=True) subprocess.run(["make"], check=True) display_checkmark("\033[92mHans installed successfully!\033[0m") os.remove("/root/hans-1.1.tar.gz") pass def icmp3_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.100"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def hns_icmp_kharej1(): display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) hans_directory = "/root/hans-1.1" os.chdir(hans_directory) os.system(f"./hans -s 80.1.2.0 -p azumi86chwan -d icmp") hans_kharej_command = f"{hans_directory}/hans -s 80.1.2.0 -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_kharej_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_kharej_command}\n") subprocess.run( ["chmod", "700", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def icmp4_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") result = subprocess.run( ["ping", "-c", "2", "80.1.2.1"], capture_output=True, text=True ) if result.returncode == 0: print(result.stdout) else: print("\033[91mPinging failed:\033[0m", result.stderr) except subprocess.CalledProcessError as e: print("\033[91mPinging failed:\033[0m", e) def hns_icmp_iran1(): display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") local_subnet = input("\033[93mEnter \033[92mIRAN\033[93m Subnet: \033[0m") remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") remote_subnet = input("\033[93mEnter \033[92mkharej\033[93m Subnet: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_strongsw_icmp(local_ip, local_subnet, remote_ip, remote_subnet, psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/hans-1.1") os.system(f"./hans -c {remote_ip} -p azumi86chwan -d icmp") subprocess.call(["rm", "-f", "/etc/cron.d/hans"]) hans_command = f"/root/hans-1.1/hans -c {remote_ip} -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_command}\n") icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.100\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") # icmp address def hans_V42(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mHans Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[96mIRAN \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": hns_icmp_kharej2() break elif server_type == "2": hns_icmp_iran2() break elif server_type == "3": os.system("clear") hans_V41() break else: print("Invalid choice.") def config_hansk_icmp(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=80.1.2.1/32 leftid=80.1.2.1 right=80.1.2.100 rightsubnet=80.1.2.100/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'80.1.2.100 80.1.2.1 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def config_hansi_icmp(psk): print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mInstalling IPSEC..\033[0m") install_process = subprocess.Popen(["sudo", "apt", "install", "strongswan", "-y"]) install_process.wait() print("IPSEC Installation complete.") subprocess.run( ["sudo", "rm", "/etc/ipsec.conf"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "rm", "/etc/ipsec.secrets"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) with open("/etc/ipsec.conf", "w") as f: f.write( f"""config setup ##azumiisinyouarea conn ipsecsit left=%defaultroute leftsubnet=80.1.2.100/32 leftid=80.1.2.100 right=80.1.2.1 rightsubnet=80.1.2.1/32 ike=aes256gcm16-sha512-ecp384! esp=aes256gcm16-sha512-ecp384! keyexchange=ikev2 auto=start authby=secret keyingtries=%forever dpdaction=restart dpddelay=30s dpdtimeout=120s rekeymargin=3m rekeyfuzz=100% reauth=no""" ) with open("/etc/ipsec.secrets", "w") as f: f.write(f'80.1.2.1 80.1.2.100 : PSK "{psk}"\n') permissions() subprocess.run( ["sudo", "systemctl", "enable", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan-starter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "enable", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( ["sudo", "systemctl", "restart", "strongswan"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) def hns_icmp_kharej2(): display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_hansk_icmp(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) hans_directory = "/root/hans-1.1" os.chdir(hans_directory) os.system(f"./hans -s 80.1.2.0 -p azumi86chwan -d icmp") hans_kharej_command = f"{hans_directory}/hans -s 80.1.2.0 -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_kharej_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_kharej_command}\n") subprocess.run( ["chmod", "700", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp3_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def hns_icmp_iran2(): display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") up_up() remote_ip = input("\033[93mEnter \033[92mkharej\033[93m IPV4 address: \033[0m") psk = input("\033[93mEnter the \033[92mSecret key\033[93m: \033[0m") config_hansi_icmp(psk) if not os.path.exists("/root/hans-1.1"): hanss_install_menu() subprocess.run( ["echo", "1", ">", "/proc/sys/net/ipv4/icmp_echo_ignore_all"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.chdir("/root/hans-1.1") os.system(f"./hans -c {remote_ip} -p azumi86chwan -d icmp") subprocess.call(["rm", "-f", "/etc/cron.d/hans"]) hans_command = f"/root/hans-1.1/hans -c {remote_ip} -p azumi86chwan -d icmp" subprocess.run( ["sed", "-i", f"/{hans_command}/d", "/etc/hans.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=False, ) if os.path.exists("/etc/hans.sh"): os.remove("/etc/hans.sh") with open("/etc/hans.sh", "w") as f: f.write(f"{hans_command}\n") icmp2_cron_job() display_checkmark("\033[92mCronjob added successfully!\033[0m") icmp4_ping() print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.1.2.100\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") def up_up(): ulimit_setting = "ulimit -n 65535" bashrc_path = os.path.expanduser("~/.bashrc") with open(bashrc_path, "r") as f: existing_bashrc = f.read() if ulimit_setting not in existing_bashrc: with open(bashrc_path, "a") as f: f.write("\n") f.write(ulimit_setting) f.write("\n") sysctl_conf_path = "/etc/sysctl.conf" sysctl_params = [ "net.core.rmem_max=26214400", "net.core.rmem_default=26214400", "net.core.wmem_max=26214400", "net.core.wmem_default=26214400", "net.core.netdev_max_backlog=2048", ] with open(sysctl_conf_path, "r") as f: existing_sysctl_conf = f.read() params_to_add = [] for param in sysctl_params: if param not in existing_sysctl_conf: params_to_add.append(param) if params_to_add: with open(sysctl_conf_path, "a") as f: f.write("\n") f.write("\n".join(params_to_add)) f.write("\n") try: subprocess.run( ["sudo", "sysctl", "-p"], stderr=subprocess.DEVNULL, check=True ) display_checkmark("\033[92mIt is Done!\033[0m") except subprocess.CalledProcessError: print("\033[91mAn error occurred while setting it up.\033[0m") else: display_checkmark("\033[92mIt was already Done.\033[0m") def icmp_uninstall(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmp Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mIcmpV4 Method 1 \033[0m") print("2. \033[96mHans Method 2 \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove2_icmp() break elif server_type == "2": remove2_hans() break elif server_type == "3": os.system("clear") remove_menu() break else: print("Invalid choice.") def icmp_uninstall_later(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIcmp Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mNo IPsec \033[0m") print("2. \033[96m/w IPsec \033[0m") print("3. \033[94mBack to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_vxlan() break elif server_type == "2": remove_vxlansec() break elif server_type == "3": os.system("clear") remove_menu() break else: print("Invalid choice.") def ipsecs3_uninstall(): delete_cron1() delete_cron2() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Erspan + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "systemctl stop strongswan-starter > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "systemctl disable strongswan > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "systemctl stop strongswan > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "apt purge strongswan -y", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "systemctl stop ping_espan.service > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo ip link delete azumiespn > /dev/null", shell=True, stdout=devnull, stderr=devnull, ) subprocess.run("apt purge strongswan -y", shell=True) devnull.close() display_checkmark("\033[92mUninstall completed!\033[0m") def remove2_hans(): os.system("clear") display_notification("\033[93mRemoving Hans ...\033[0m") print("\033[93m╭───────────────────────────────────────╮\033[0m") reset_icmp() ipsecs3_uninstall() espn_uninstall() try: if subprocess.call("test -f /etc/hans.sh", shell=True) == 0: subprocess.run("rm /etc/hans.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/hans.sh" | crontab -', shell=True, ) subprocess.run( "rm /etc/systemd/system/azumifrps1.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev icmp down > /dev/null", shell=True) subprocess.run("ip link set dev icmp down > /dev/null", shell=True) print("Progress: ", end="") try: lsof_process = subprocess.Popen( ["lsof", "/root/hans-1.1/hans"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) lsof_output, lsof_error = lsof_process.communicate() if lsof_output: pid = lsof_output.decode().split("\n")[1].split()[1] subprocess.run(["kill", pid]) subprocess.run(["rm", "-rf", "/root/hans-1.1"]) except FileNotFoundError: print("Error: Directory '/root/hans-1.1' does not exist.") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except Exception as e: print("An error occurred during uninstallation:", str(e)) except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove2_icmp(): os.system("clear") display_notification("\033[93mRemoving icmp...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") reset_icmp() ipsecs3_uninstall() espn_uninstall() try: subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/icmp.sh" | crontab -', shell=True, ) subprocess.run("ip link set dev tun0 down > /dev/null", shell=True) subprocess.run("ip link set dev tun1 down > /dev/null", shell=True) subprocess.run("systemctl daemon-reload", shell=True) print("Progress: ", end="") try: lsof_process = subprocess.Popen( ["lsof", "-t", "/root/icmpv4/icmptunnel"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) lsof_output, lsof_error = lsof_process.communicate() if lsof_output: pids = lsof_output.decode().split("\n")[:-1] for pid in pids: subprocess.run(["kill", pid]) subprocess.run(["rm", "-rf", "/root/icmpv4"]) except FileNotFoundError: print("Error: Directory '/root/icmpv4' does not exist.") subprocess.run( 'crontab -l | grep -v "/bin/bash /etc/icmp.sh" | crontab -', shell=True ) display_checkmark("\033[92mUninstall completed!\033[0m") if os.path.isfile("/etc/icmp.sh"): os.remove("/etc/icmp.sh") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def gre6tapespn_uninstall(): delete_cron1() delete_cron2() remove_private() remove_gre6tap21() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Erspan + \033[92mGRE6tap Tunnel\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_espan.sh", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("sudo ip link delete azumiespn > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def gre6test_uninstall(): delete_cron1() delete_cron2() remove_private() remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Erspan + \033[92mGRE6 Tunnel\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh", shell=True) if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_espan.sh", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("sudo ip link delete azumiespn > /dev/null", shell=True) subprocess.run("sudo ip link delete azumip6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def espn_uninstall(): delete_cron1() delete_cron2() print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Erspan Tunnel\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/spn.sh", shell=True) == 0: subprocess.run("rm /etc/spn.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/spn.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_espan.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_espan.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_espan.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumiespn > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) ## gre6tap remove def gre6tapsec_remove(): # inja remove_private() remove_gre6tap21() ipsecs_uninstall_gre6tap() def gre6tap_remove(): remove_private() remove_gre6tap21() #### def genx_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[92mGeneve\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve \033[0m") print("2. \033[93mGeneve + Native \033[0m") print("3. \033[96mGeneve + Gre6 + Native \033[0m") print("4. \033[92mGeneve + Gre6 + IPV4 \033[0m") print("5. \033[93mGeneve + IP6tnl + Gre6 + Native \033[0m") print("6. \033[92mGeneve + IPsec \033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genz_uninstall() break elif server_type == "2": genz_uninstall() break elif server_type == "3": gen2_uninstall() break elif server_type == "5": gen4_uninstall() break elif server_type == "6": remove_test() break elif server_type == "4": gen6_uninstall() break elif server_type == "0": clear() remove_menu() break else: print("Invalid choice.") ## gen ic def reset_icmp(): try: reset_ipv4 = False reset_ipv6 = False os.system("sysctl -w net.ipv4.icmp_echo_ignore_all=0") reset_ipv4 = True os.system("sudo sysctl -w net.ipv6.icmp.echo_ignore_all=0") reset_ipv6 = True if reset_ipv4 or reset_ipv6: display_checkmark("\033[92mICMP has been reset to default!\033[0m") else: display_notification("\033[93mICMP settings has been reset.\033[0m") except Exception as e: display_error("\033[91mAn error occurred: {}\033[0m".format(str(e))) def install_icmp(): print("\033[93m──────────────────────────────────────────────────\033[0m") display_loading() subprocess.run( ["sudo", "tee", "/etc/resolv.conf"], input="nameserver 1.1.1.1\n", capture_output=True, text=True, ) ipv4_forward_status = subprocess.run( ["sysctl", "net.ipv4.ip_forward"], capture_output=True, text=True ) if "net.ipv4.ip_forward = 0" not in ipv4_forward_status.stdout: subprocess.run(["sudo", "sysctl", "-w", "net.ipv4.ip_forward=1"]) ipv6_forward_status = subprocess.run( ["sysctl", "net.ipv6.conf.all.forwarding"], capture_output=True, text=True ) if "net.ipv6.conf.all.forwarding = 0" not in ipv6_forward_status.stdout: subprocess.run(["sudo", "sysctl", "-w", "net.ipv6.conf.all.forwarding=1"]) if os.path.exists("/root/icmpv4"): shutil.rmtree("/root/icmpv4") clone_command = "git clone https://github.com/miyugundam/icmp.git icmpv4" clone_result = os.system(clone_command) if clone_result != 0: print("Error: Failed to clone Repo.") return if os.path.exists("/root/icmpv4"): os.chdir("/root/icmpv4") subprocess.run( ["sudo", "apt", "install", "-y", "net-tools"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "make"], capture_output=True, text=True ) subprocess.run( ["sudo", "apt-get", "install", "-y", "libssl-dev"], capture_output=True, text=True, ) subprocess.run( ["sudo", "apt", "install", "-y", "g++"], capture_output=True, text=True ) subprocess.run(["make"], capture_output=True, text=True) os.chdir("..") else: display_error("\033[91micmptunnel folder not found.\033[0m") def up_up(): ulimit_setting = "ulimit -n 65535" bashrc_path = os.path.expanduser("~/.bashrc") with open(bashrc_path, "r") as f: existing_bashrc = f.read() if ulimit_setting not in existing_bashrc: with open(bashrc_path, "a") as f: f.write("\n") f.write(ulimit_setting) f.write("\n") sysctl_conf_path = "/etc/sysctl.conf" sysctl_params = [ "net.core.rmem_max=26214400", "net.core.rmem_default=26214400", "net.core.wmem_max=26214400", "net.core.wmem_default=26214400", "net.core.netdev_max_backlog=2048", ] with open(sysctl_conf_path, "r") as f: existing_sysctl_conf = f.read() params_to_add = [] for param in sysctl_params: if param not in existing_sysctl_conf: params_to_add.append(param) if params_to_add: with open(sysctl_conf_path, "a") as f: f.write("\n") f.write("\n".join(params_to_add)) f.write("\n") try: subprocess.run( ["sudo", "sysctl", "-p"], stderr=subprocess.DEVNULL, check=True ) display_checkmark("\033[92mLimit has been Set!\033[0m") except subprocess.CalledProcessError: print("\033[91mAn error occurred setting it up.\033[0m") else: display_checkmark("\033[92mLimit Increase was already Done.\033[0m") def ic_kharej(): if not os.path.exists("/root/icmpv4"): install_icmp() up_up() print("\033[93m──────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring Kharej ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") if os.path.exists("/etc/icmp.sh"): os.remove("/etc/icmp.sh") with open("/etc/icmp.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/root/icmpv4/icmptunnel -s -d\n") f.write("/sbin/ifconfig tun0 70.0.0.1 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp.sh") cron_job_command = "@reboot root /bin/bash /etc/icmp.sh\n" with open("/etc/cron.d/icmp-kharej", "a") as f: f.write(cron_job_command) subprocess.call("crontab -u root /etc/cron.d/icmp-kharej", shell=True) display_checkmark("\033[92mCronjob added successfully!\033[0m") def ic_iran(): if not os.path.exists("/root/icmpv4"): install_icmp() up_up() print("\033[93m──────────────────────────────────────────────────\033[0m") display_notification("\033[93mConfiguring IRAN ...\033[0m") print("\033[93m──────────────────────────────────────────────────\033[0m") os.chdir("/root/icmpv4") server_ipv4 = input("\033[93mEnter \033[92mKharej\033[93m IPv4 address:\033[0m ") if os.path.exists("/etc/icmp-iran.sh"): os.remove("/etc/icmp-iran.sh") with open("/etc/icmp-iran.sh", "w") as f: f.write("#!/bin/bash\n") f.write(f"/root/icmpv4/icmptunnel {server_ipv4} -d\n") f.write("/sbin/ifconfig tun0 70.0.0.2 netmask 255.255.255.0\n") subprocess.run( ["chmod", "700", "/etc/icmp-iran.sh"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, check=True, ) os.system("/bin/bash /etc/icmp-iran.sh") cron_job_command = "@reboot root /bin/bash /etc/icmp-iran.sh\n" with open("/etc/cron.d/icmp-iran", "a") as f: f.write(cron_job_command) subprocess.call("crontab -u root /etc/cron.d/icmp-iran", shell=True) display_checkmark("\033[92mCronjob added successfully!\033[0m") def gen_ipicmp(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_icmpk_version1() break elif server_type == "2": geneve_icmpk_version2() break else: print("Invalid choice.") def geneve_icmpk_version1(): ic_kharej() ufw("66.200.1.1") ufw("66.200.2.1") ufw("70.0.0.1") ufw("70.0.0.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "70.0.0.2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_icmpk_version2(): ic_kharej() ufw("70.0.0.1") ufw("70.0.0.2") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "70.0.0.2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen_ipicmpi(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_icmpi_version1() break elif server_type == "2": geneve_icmpi_version2() break else: print("Invalid choice.") def geneve_icmpi_version1(): ic_iran() ufw("66.200.1.1") ufw("66.200.2.1") ufw("70.0.0.1") ufw("70.0.0.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "70.0.0.1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_icmpi_version2(): ic_iran() ufw("70.0.0.1") ufw("70.0.0.2") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "70.0.0.1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def rmv_limit(): display_notification("\033[93mRestoring Limit ..\033[0m") print("\033[93m───────────────────────────────────────\033[0m") ulimit_setting = "ulimit -n 65535" bashrc_path = os.path.expanduser("~/.bashrc") with open(bashrc_path, "r") as f: existing_bashrc = f.read() if ulimit_setting in existing_bashrc: existing_bashrc = existing_bashrc.replace(ulimit_setting, "") with open(bashrc_path, "w") as f: f.write(existing_bashrc) sysctl_conf_path = "/etc/sysctl.conf" sysctl_params = [ "net.core.rmem_max=26214400", "net.core.rmem_default=26214400", "net.core.wmem_max=26214400", "net.core.wmem_default=26214400", "net.core.netdev_max_backlog=2048", ] with open(sysctl_conf_path, "r") as f: existing_sysctl_conf = f.read() params_to_remove = [] for param in sysctl_params: if param in existing_sysctl_conf: params_to_remove.append(param) if params_to_remove: for param in params_to_remove: existing_sysctl_conf = existing_sysctl_conf.replace(param, "") with open(sysctl_conf_path, "w") as f: f.write(existing_sysctl_conf) try: subprocess.run( ["sudo", "sysctl", "-p"], stderr=subprocess.DEVNULL, check=True ) display_checkmark("\033[92mLimit removal was Successful!\033[0m") except subprocess.CalledProcessError: print("\033[91mAn error occurred.\033[0m") else: display_checkmark("\033[92mNothin was found! moving on..\033[0m") def remove_icmp(): print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving icmp...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/icmp.sh" | crontab -', shell=True, ) subprocess.run("ip link set dev tun0 down > /dev/null", shell=True) subprocess.run("ip link set dev tun1 down > /dev/null", shell=True) subprocess.run("apt install lsof -y", shell=True) subprocess.run("systemctl daemon-reload", shell=True) print("Progress: ", end="") try: lsof_process = subprocess.Popen( ["lsof", "-t", "/root/icmpv4/icmptunnel"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) lsof_output, lsof_error = lsof_process.communicate() if lsof_output: pids = lsof_output.decode().split("\n")[:-1] for pid in pids: subprocess.run(["kill", pid]) subprocess.run(["rm", "-rf", "/root/icmpv4"]) except FileNotFoundError: print("Error: Directory 'icmp' does not exist.") except Exception as e: print("Error:", e) subprocess.run( 'crontab -l | grep -v "/bin/bash /etc/icmp.sh" | crontab -', shell=True ) subprocess.run( 'crontab -l | grep -v "/bin/bash /etc/icmp-iran.sh" | crontab -', shell=True ) display_checkmark("\033[92mICMPtunnel Uninstallation completed!\033[0m") if os.path.isfile("/etc/icmp.sh"): os.remove("/etc/icmp.sh") if os.path.isfile("/etc/icmp-iran.sh"): os.remove("/etc/icmp-iran.sh") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", e) def ipsecs_uninstall_gre6(): delete_cron1() delete_cron2() remove_private() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving GRE6 + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run("systemctl daemon-reload", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def ipsecs_uninstall_gre6tap(): delete_cron1() delete_cron2() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving GRE6tap + \033[92mIpsec \033[93m+ Tunnels\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") try: devnull = open(os.devnull, "w") subprocess.run( "sudo rm /etc/ipsec.conf", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "sudo rm /etc/ipsec.secrets", shell=True, stdout=devnull, stderr=devnull ) subprocess.run( "systemctl disable strongswan-starter > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop strongswan-starter > /dev/null 2>&1", shell=True) subprocess.run("systemctl disable strongswan > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop strongswan > /dev/null 2>&1", shell=True) subprocess.run("apt purge strongswan -y", shell=True) subprocess.run("systemctl daemon-reload", shell=True) devnull.close() print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def remove_gre6sec(): remove_gre6() ipsecs_uninstall_gre6() def remove_ipip6sec(): remove_ipip6() ipsecs_uninstall_ipip() def remove_ipip6(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mIPIP6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/ipip.sh", shell=True) == 0: subprocess.run("rm /etc/ipip.sh", shell=True) if subprocess.call("test -f /etc/private.sh", shell=True) == 0: subprocess.run("rm /etc/private.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipip.sh" | crontab -', shell=True, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_v6.sh", shell=True) sleep(1) subprocess.run("sudo rm /etc/ping_ip.sh", shell=True) subprocess.run("systemctl disable ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v6.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl disable ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip.service > /dev/null 2>&1", shell=True ) sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumip down > /dev/null", shell=True) subprocess.run("ip tunnel del azumip > /dev/null", shell=True) sleep(1) subprocess.run("ip link set dev azumi down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 3 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def i6to41_any(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93m6to4 \033[92m[Anycast]\033[93m Menu\033[0m") print('\033[92m "-"\033[93m════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": i6to41_any_kharej() elif server_type == "2": i6to41_any_iran() elif server_type == "3": clear() multiserver_mnu() else: print("Invalid choice.") def i6to41_any_kharej(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6to4 \033[92mKharej\033[93m Menu\033[92m[Anycast]\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════\033[0m') if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring Kharej..\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej IPv4\033[93m address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote any local {} ttl 255\n".format( local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev azumi6 metric 1\n" ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = input( "\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + int(num_ips)): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") config_file_path = "/etc/6to4.sh" subprocess.run( f"(crontab -l | grep -v -F '{config_file_path}') | crontab -", shell=True, check=True, ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) display_notification("\033[93mStarting 6to4...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) num_servers = int( input( "\033[93mEnter the \033[92mnumber\033[93m of \033[96mServers\033[93m[Ping Service]? \033[0m" ) ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") for i in range(num_servers): remote_ipv4 = input( f"\033[93mEnter \033[96mIPv4 address\033[93m of server \033[92m{i+1} [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = """#!/bin/bash ip_address="{}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ script_filename = f"/etc/ping_v6{i+1}.sh" with open(script_filename, "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", script_filename]) service_filename = f"/etc/systemd/system/ping_v6{i+1}.service" with open(service_filename, "w") as f: f.write("[Unit]\n") f.write(f"Description=Ping Service {i+1}\n") f.write("After=network.target\n") f.write("\n") f.write("[Service]\n") f.write(f"ExecStart=/bin/bash {script_filename}\n") f.write("Restart=always\n") f.write("\n") f.write("[Install]\n") f.write("WantedBy=multi-user.target\n") subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", f"ping_v6{i+1}.service"]) subprocess.run(["systemctl", "start", f"ping_v6{i+1}.service"]) sleep(1) subprocess.run(["systemctl", "restart", f"ping_v6{i+1}.service"]) print( f"\033[92mPing service for server {i+1} has been added successfully!\033[0m" ) print( "\033[93m─────────────────────────────────────────────────────────\033[0m" ) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") ##### saki _ gretap def gree6_tunnel(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree6_kharej(): remote_ip = "2002:831b::2" # iran-ip local_ip = "2002:831b::1" # kharej ip gree6_tunnel(remote_ip, local_ip) ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() # sit kharej def kharej_gree6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve + GRE Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(" \033[93mConfiguring \033[92mKharej\033[93m server\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add 2002:831b::1/64 dev azumi\n") f.write("ip -6 route add 2002::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gree6_kharej() sleep(1) ##### IRAN gre6 def iran_ping(): try: subprocess.run( ["ping", "-c", "2", "2002:831b::1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def gree6_iran_tunnel(remote_ip, local_ip): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) subprocess.run(rt_command, shell=True, check=True) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree6_iran(): remote_ip = "2002:831b::1" # kharej ip local_ip = "2002:831b::2" # iran ip gree6_iran_tunnel(remote_ip, local_ip) ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() # sit iran def iran_gree6_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve + GRE Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mConfiguring \033[92mIran\033[93m server\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "sit", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe sit\n") f.write( f"ip tunnel add azumi mode sit remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip link set dev azumi up\n") f.write("ip addr add 2002:831b::2/64 dev azumi\n") f.write("ip -6 route add 2002::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gree6_iran() sleep(1) def genf_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGR6 + Geneve Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGRE + Native Geneve\033[0m") print("2. \033[96mIP6tnl + GRE + Native Geneve\033[0m") print("3. \033[93mGRE + IPV4 Geneve\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genfm_ip() break elif server_type == "2": genf3_ip() break elif server_type == "3": genf5_ip() break elif server_type == "0": clear() genz_ip() break else: print("Invalid choice.") # sit gre gen def kharej_gree61_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve + GRE Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") print(" \033[93mConfiguring \033[92mKharej\033[93m server\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw("2002:831b::2") ufw("2002:831b::1") subprocess.run( [ "ip", "tunnel", "add", "azumi", "mode", "ip6ip6", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::1/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumi mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::1/64 dev azumi\n") f.write("ip -6 route add 2002::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") run_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gree61_kharej1() sleep(1) def iran_gree61_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve + GRE Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mConfiguring \033[92mIran\033[93m server\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/private.sh"): os.remove("/etc/private.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw("2002:831b::2") ufw("2002:831b::1") subprocess.run( [ "ip", "-6", "tunnel", "add", "azumi", "mode", "ip6ip6", "remote", remote_ip, "local", local_ip, "ttl", "255", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["ip", "-6", "link", "set", "dev", "azumi", "up"], stdout=subprocess.DEVNULL ) initial_ip = "2002:831b::2/64" subprocess.run( ["ip", "addr", "add", initial_ip, "dev", "azumi"], stdout=subprocess.DEVNULL ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/private.sh", "w") as f: f.write("/sbin/modprobe ipip\n") f.write( f"ip -6 tunnel add azumi mode ip6ip6 remote {remote_ip} local {local_ip} ttl 255\n" ) f.write("ip -6 link set dev azumi up\n") f.write("ip -6 addr add 2002:831b::2/64 dev azumi\n") f.write("ip -6 route add 2002::/16 dev azumi\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [6to4]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumi mtu {mtu_value}\n" with open("/etc/private.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mPrivate ip added successfully!\033[0m") file_path = "/etc/private.sh" command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) sleep(1) add_cron_job() display_checkmark("\033[92mkeepalive service Configured!\033[0m") iran_ping() sleep(1) script_content1 = """#!/bin/bash ip_address="2002:831b::1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_v6.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_v6.sh", 0o755) ping_v6_service() display_notification("\033[93mConfiguring...\033[0m") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gree61_iran1() sleep(1) def gree61_kharej1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote 2002:831b::2 local 2002:831b::1 ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree61_kharej1(): gree61_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def gree61_iran1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote 2002:831b::1 local 2002:831b::2 ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree61_iran1(): gree61_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def genf3_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 + IP6tnl \033[93mMenu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen1_ipger() break elif server_type == "2": gen1_ipgeri() break elif server_type == "3": clear() genf_ip() break else: print("Invalid choice.") def gen1_ipger(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_gerk1_version1() break elif server_type == "2": geneve_gerk1_version2() break else: print("Invalid choice.") def geneve_gerk1_version1(): kharej_gree61_menu() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_gerk1_version2(): kharej_gree61_menu() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen1_ipgeri(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_geri1_version1() break elif server_type == "2": geneve_geri1_version2() break else: print("Invalid choice.") def geneve_geri1_version1(): iran_gree61_menu() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_geri1_version2(): iran_gree61_menu() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## method 1 def genfm_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGR6 + Geneve Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1 [no route]\033[0m") print("2. \033[93mMethod 2 [/w route]\033[0m") print("0. \033[91mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genf1_ip() break elif server_type == "2": genf12_ip() break elif server_type == "0": clear() genf_ip() break else: print("Invalid choice.") def genf12_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[2]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genr_ipger() break elif server_type == "2": genr_ipgeri() break elif server_type == "3": clear() genf_ip() break else: print("Invalid choice.") def genr_ipger(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_gerkr_version1() break elif server_type == "2": geneve_gerkr_version2() break else: print("Invalid choice.") def gree6r_kharej1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw(remote_ip) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::1\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6r_kharej1(): gree6r_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def geneve_gerkr_version1(): gree6r_kharej1() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_gerkr_version2(): gree6r_kharej1() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def genr_ipgeri(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_gerir_version1() break elif server_type == "2": geneve_gerir_version2() break else: print("Invalid choice.") def gree6r_iran1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw(remote_ip) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("\033[91mError: No network interface with IPv6 address\033[0m") else: print("Interface:", interface) rt_command = "ip -6 route replace default via fe80::1 dev {} src 2002:831a::2\n".format( interface ) with open("/etc/gre6.sh", "a") as f: f.write(rt_command) else: print("Skipping changing the default route.") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) sleep(1) subprocess.run(f"bash {file_path}", shell=True, check=True) def gree6r_iran1(): gree6r_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def geneve_gerir_version1(): gree6r_iran1() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_gerir_version2(): gree6r_iran1() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def genf1_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mNative \033[93m+\033[92m Gre6 \033[93mM[1]\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_ipger() break elif server_type == "2": gen_ipgeri() break elif server_type == "3": clear() genf_ip() break else: print("Invalid choice.") def genf2_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 \033[93mMenu\033[0m" ) print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": genf5_ip() break elif server_type == "2": gen5_ipgeri() break elif server_type == "3": clear() genf_ip() break else: print("Invalid choice.") def genkh_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "66.200.2.1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def genir_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "66.200.1.1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_kh_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_gen.service"]) def gen_job(): file_path = "/etc/sys.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ufw(ip_address): subprocess.run(["sudo", "ufw", "allow", "from", ip_address]) def ufwport(port): subprocess.run(["sudo", "ufw", "allow", port]) def ufwr(): subprocess.run(["sudo", "ufw", "reload"]) def ipv4_address(): result = subprocess.run( ["curl", "-s", "https://ipinfo.io/ip"], capture_output=True, text=True ) return result.stdout.strip() def kharej1_gen_menu(): kharej_gree6_menu() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") ufw("2002:831b::1") ufw("2002:831b::2") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m Configuring Kharej server Geneve\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() genkh_ping() display_checkmark("\033[92mkeepalive service Configured!\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content1 = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content1) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Geneve Configuration Completed!\033[0m") def iran1_gen_menu(): iran_gree6_menu() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") ufw("2002:831b::1") ufw("2002:831b::2") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m Configuring Iran server Geneve\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() genir_ping() sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Geneve Configuration Completed!\033[0m") def genf5_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93mGeneve + \033[96mIPV4 \033[93m+\033[92m Gre6 \033[93mMenu\033[0m" ) print('\033[92m "-"\033[93m═══════════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen5_ipger() break elif server_type == "2": gen5_ipgeri() break elif server_type == "3": clear() genf_ip() break else: print("Invalid choice.") def gen5_ipger(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharej1_gen_menu() break elif server_type == "2": geneve_gerk6_version2() break else: print("Invalid choice.") def geneve_gerk6_version2(): kharej_gree6_menu() ufw("2002:831a::1") ufw("2002:831a::2") ufw("2002:831b::1") ufw("2002:831b::2") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen5_ipgeri(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": iran1_gen_menu() break elif server_type == "2": geneve_geri5_version2() break else: print("Invalid choice.") def geneve_geri5_version2(): iran_gree6_menu() ufw("2002:831a::1") ufw("2002:831a::2") ufw("2002:831b::1") ufw("2002:831b::2") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ## test n gre def gree6_kharej1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw(remote_ip) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::1/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree6_kharej1(): gree6_kharej1_tunnel() ip_address = "2002:831a::2" # iranip max_pings = 3 interval = 2 print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") create_ping_script(ip_address, max_pings, interval) ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) ping_gre6_service() gre6_cronjob() def gree6_iran1_tunnel(): file_path = "/etc/gre6.sh" if os.path.exists(file_path): os.remove(file_path) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) remote_ip = input( "\033[93mEnter \033[92mKharej\033[93m IPV6 address [\033[92mNative\033[93m or\033[96m Tunnelbroker\033[93m]: \033[0m" ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") ufw(remote_ip) command = f"echo '/sbin/modprobe ip6_gre' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 tunnel add azumig6 mode ip6gre remote {remote_ip} local {local_ip} ttl 255' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 addr add 2002:831a::2/64 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip link set azumig6 up' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"echo 'ip -6 route add 2002::/16 dev azumig6' >> {file_path}" subprocess.run(command, shell=True, check=True) command = f"chmod +x {file_path}" subprocess.run(command, shell=True, check=True) subprocess.run(f"bash {file_path}", shell=True, check=True) set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [GRE6]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumig6 mtu {mtu_value}\n" with open("/etc/gre6.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) sleep(1) def gree6_iran1(): gree6_iran1_tunnel() ip_address = "2002:831a::1" # kharejip max_pings = 3 interval = 2 iran_ping_script(ip_address, max_pings, interval) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", ip_address], capture_output=True, text=True ).stdout.strip() print(ping_result) iran_gre6_service() gre6_cronjob() def gen_ipger(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_gerk_version1() break elif server_type == "2": geneve_gerk_version2() break else: print("Invalid choice.") def check_gre6(): with open("/etc/gre6.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre61(): with open("/etc/gre61.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre62(): with open("/etc/gre62.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre63(): with open("/etc/gre63.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre64(): with open("/etc/gre64.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre65(): with open("/etc/gre65.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre66(): with open("/etc/gre66.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre67(): with open("/etc/gre67.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre68(): with open("/etc/gre68.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre69(): with open("/etc/gre69.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def check_gre610(): with open("/etc/gre610.sh", "r") as file: lines = file.readlines() for line in lines: if "azumig6" in line and "ip6gretap" in line: return "gre6tap" elif "azumig6" in line and "ip6gre" in line: return "gre6" return "unknown" def remote_extraction(file_path): with open(file_path, "r") as file: content = file.read() match = re.search(r"remote\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", content) if match: return match.group(1) return None def interface_ex(interface): output = subprocess.run( ["ip", "a", "show", interface], capture_output=True, text=True ) return output.returncode == 0 def interface_check(interface): output = subprocess.run( ["ip", "a", "show", interface], capture_output=True, text=True ) if output.returncode == 0: if re.search(r"state (UP|UNKNOWN)", output.stdout): return "online" return "offline" def ipsec_secret(): try: with open("/etc/ipsec.secrets", "r") as file: lines = file.readlines() for line in lines: if "PSK" in line: secret_key = line.split('"')[1] return secret_key.strip() except FileNotFoundError: pass return "Not found" def checktype(file_path): with open(file_path, "r") as file: contents = file.read() if "::2/64" in contents: return "Kharej" elif "::1/64" in contents: return "IRAN" def checktype3(file_path): with open(file_path, "r") as file: contents = file.read() if "::2/64" in contents: return "IRAN" elif "::1/64" in contents: return "KHAREJ" def checktypegen2(file_path): with open(file_path, "r") as file: contents = file.read() if "::2/16" in contents: return "IRAN" elif "::1/16" in contents: return "KHAREJ" def checktypegen(file_path): with open(file_path, "r") as file: contents = file.read() if "::2/16" in contents: return "Kharej" elif "::1/16" in contents: return "IRAN" elif ( "sudo ip addr add 66.200.2.1/32" in contents or "sudo ip addr add 80.200.1.2/32" in contents ): return "Kharej" elif "sudo ip addr add 66.200.1.1/32" in contents: return "IRAN" return None def checktype2(path): with open(path, "r") as file: contents = file.read() if "::2/16" in contents: return "Kharej" elif "::1/16" in contents: return "IRAN" return None def multi_status(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mMulti Status Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭─────────────────────────────────────────────────╮\033[0m") print("\033[93mYou are viewing the status of your current tunnels:\033[0m") interfaces = [ "azumi1", "azumi2", "azumi3", "azumi4", "azumi5", "azumi6", "azumi7", "azumi8", "azumi9", "azumip1", "azumip2", "azumip3", "azumip4", "azumip5", "azumip6", "azumip7", "azumip8", "azumip9", "azumip10", "azumig61", "azumig62", "azumig63", "azumig64", "azumig65", "azumig66", "azumig67", "azumig68", "azumig69", "azumig610", "azumigen1", "azumigen2", "azumigen3", "azumigen4", "azumigen5", "azumi10", ] active_int = [] for interface in interfaces: if interface_ex(interface): status = interface_check(interface) if status == "online": active_int.append(interface) if not active_int: print(" No Interfaces available.") elif "azumigen5" in active_int and "azumig65" in active_int: with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( "\033[93m─────────────────────────────────────────────────\033[0m" ) print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumig65, azumigen5\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 6): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen4" in active_int and "azumig64" in active_int: with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumig64, azumigen4\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen3" in active_int and "azumig63" in active_int: with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumig63, azumigen3\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen2" in active_int and "azumig62" in active_int: with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumig62, azumigen2\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen1" in active_int and "azumig61" in active_int: with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumig61, azumigen1\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 1 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") private_files = ["/etc/private1.sh"] for private_file in private_files: if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig610" in active_int and "azumi10" in active_int: gre6_method10 = check_gre610() if gre6_method10 == "gre6tap": with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi10, azumig610\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m10 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m10 \033[92mOnline\033[0m" ) else: if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m10 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 10 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 11): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method10 == "gre6": with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi10, azumig610\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m10 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m10 \033[92mOnline\033[0m" ) else: if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m10 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 10 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 11): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private10.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig69" in active_int and "azumi9" in active_int: gre6_method9 = check_gre69() if gre6_method9 == "gre6tap": with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi9, azumig69\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m9 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m9 \033[92mOnline\033[0m" ) else: if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m9 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 9 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 10): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method9 == "gre6": with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi9, azumig69\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m9 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m9 \033[92mOnline\033[0m" ) else: if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m9 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 9 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 10): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private9.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig68" in active_int and "azumi8" in active_int: gre6_method8 = check_gre68() if gre6_method8 == "gre6tap": with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi8, azumig68\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m8 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m8 \033[92mOnline\033[0m" ) else: if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m8 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 8 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 9): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method8 == "gre6": with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi8, azumig68\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m8 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m8 \033[92mOnline\033[0m" ) else: if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m8 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 8 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 9): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private8.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig67" in active_int and "azumi7" in active_int: gre6_method7 = check_gre67() if gre6_method7 == "gre6tap": with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi7, azumig67\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m7 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m7 \033[92mOnline\033[0m" ) else: if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m7 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 7 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 8): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method7 == "gre6": with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi7, azumig67\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m7 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m7 \033[92mOnline\033[0m" ) else: if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m7 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 7 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 8): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private7.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig66" in active_int and "azumi6" in active_int: gre6_method6 = check_gre66() if gre6_method6 == "gre6tap": with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi6, azumig66\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m6 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m6 \033[92mOnline\033[0m" ) else: if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m6 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 6 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 7): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method6 == "gre6": with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi6, azumig66\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m6 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m6 \033[92mOnline\033[0m" ) else: if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m6 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 6 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 7): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private6.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig65" in active_int and "azumi5" in active_int: gre6_method5 = check_gre65() if gre6_method5 == "gre6tap": with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi5, azumig65\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 6): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method5 == "gre6": with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi5, azumig65\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 6): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private5.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig64" in active_int and "azumi4" in active_int: gre6_method4 = check_gre64() if gre6_method4 == "gre6tap": with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi4, azumig64\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method4 == "gre6": with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi4, azumig64\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private4.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig63" in active_int and "azumi3" in active_int: gre6_method3 = check_gre63() if gre6_method3 == "gre6tap": with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi3, azumig63\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method3 == "gre6": with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi3, azumig63\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private3.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig62" in active_int and "azumi2" in active_int: gre6_method2 = check_gre62() if gre6_method2 == "gre6tap": with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi2, azumig62\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method2 == "gre6": with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi2, azumig62\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private2.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumig61" in active_int and "azumi1" in active_int: gre6_method1 = check_gre61() if gre6_method1 == "gre6tap": with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi1, azumig61\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[96m1 \033[97local Tunnel \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 2): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif gre6_method1 == "gre6": with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumi1, azumig61\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): if "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[96m1 \033[97local Tunnel \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 2): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/private1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip10" in active_int and "azumi10" in active_int: with open("/etc/private10.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip10, azumi10\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip10" in active_int and "azumip9" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m10 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m10 \033[92mOnline\033[0m" ) else: if "azumip10" in active_int and "azumip9" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m10 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 10 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 11): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip9" in active_int and "azumi9" in active_int: with open("/etc/private9.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip9, azumi9\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip9" in active_int and "azumip8" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m9 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m9 \033[92mOnline\033[0m" ) else: if "azumip9" in active_int and "azumip8" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m9 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 9 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 10): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip8" in active_int and "azumi8" in active_int: with open("/etc/private8.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip8, azumi8\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip8" in active_int and "azumip7" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m8 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m8 \033[92mOnline\033[0m" ) else: if "azumip8" in active_int and "azumip7" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m8 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 8 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 9): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip7" in active_int and "azumi7" in active_int: with open("/etc/private7.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip7, azumi7\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip7" in active_int and "azumip6" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m7 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m7 \033[92mOnline\033[0m" ) else: if "azumip7" in active_int and "azumip6" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m7 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 7 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 8): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip6" in active_int and "azumi6" in active_int: with open("/etc/private6.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip6, azumi6\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip6" in active_int and "azumip5" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m6 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m6 \033[92mOnline\033[0m" ) else: if "azumip6" in active_int and "azumip5" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m6 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 6 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 7): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip5" in active_int and "azumi5" in active_int: with open("/etc/private5.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip5, azumi5\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip5" in active_int and "azumip4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumip5" in active_int and "azumip4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 6): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip4" in active_int and "azumi4" in active_int: with open("/etc/private4.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip4, azumi4\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip4" in active_int and "azumip3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumip4" in active_int and "azumip3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip3" in active_int and "azumi3" in active_int: with open("/etc/private3.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip3, azumi3\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip3" in active_int and "azumip2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumip3" in active_int and "azumip2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip2" in active_int and "azumi2" in active_int: with open("/etc/private2.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip2, azumi2\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip2" in active_int and "azumip1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumip2" in active_int and "azumip1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumip1" in active_int and "azumi1" in active_int: with open("/etc/private1.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print("\033[93m─────────────────────────────────────────────────\033[0m") print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names examples:\033[96m azumip2, azumi2\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") if iran_server: if "azumip1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[96m1 \033[97mlocal Tunnel\033[96m \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 2): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif os.path.exists("/etc/6to4.sh") and "azumi6" in active_int: with open("/etc/6to4.sh", "r") as file: contents = file.read() match = re.search(r"::2/16", contents) if match: if match.start() < contents.index("::1/16"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi6\033[0m" ) print(" \033[93mTunnel Method: \033[97m6to4 Sit\033[0m") elif "azumi10" in active_int: with open("/etc/private10.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi10\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m10 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m10 \033[92mOnline\033[0m" ) else: if "azumi10" in active_int and "azumi9" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m10 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 10 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 11): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi9" in active_int: with open("/etc/private9.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi9\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m9 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m9 \033[92mOnline\033[0m" ) else: if "azumi9" in active_int and "azumi8" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m9 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 9 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 10): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi8" in active_int: with open("/etc/private8.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi8\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m8 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m8 \033[92mOnline\033[0m" ) else: if "azumi8" in active_int and "azumi7" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m8 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 8 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 9): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi7" in active_int: with open("/etc/private7.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi7\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m7 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m7 \033[92mOnline\033[0m" ) else: if "azumi7" in active_int and "azumi6" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m7 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 7 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 8): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi6" in active_int: with open("/etc/private6.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi6\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m6 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m6 \033[92mOnline\033[0m" ) else: if "azumi6" in active_int and "azumi5" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m6 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 6 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 7): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi5" in active_int: with open("/etc/private5.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi5\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumi5" in active_int and "azumi4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 6): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi4" in active_int: with open("/etc/private4.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi4\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumi4" in active_int and "azumi3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi3" in active_int: with open("/etc/private3.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi3\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumi3" in active_int and "azumi2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi2" in active_int: with open("/etc/private2.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi2\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumi2" in active_int and "azumi1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumi1" in active_int: with open("/etc/private1.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi5\033[0m" ) print(" \033[93mTunnel Method: \033[97m6TO4 Sit\033[0m") if iran_server: if "azumi1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: if "azumi1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m1 \033[97mlocal Tunnel\033[96m \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 2): private_file = f"/etc/private{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen5" in active_int: with open("/etc/sys5.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen5\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") if iran_server: if "azumigen5" in active_int and "azumigen4" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m5 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m5 \033[92mOnline\033[0m" ) else: if "azumigen5" in active_int and "azumigen4" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m5 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 5 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/sys{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen4" in active_int: with open("/etc/sys4.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen4\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") if iran_server: if "azumigen4" in active_int and "azumigen3" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m4 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m4 \033[92mOnline\033[0m" ) else: if "azumigen4" in active_int and "azumigen3" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m4 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 4 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 5): private_file = f"/etc/sys{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen3" in active_int: with open("/etc/sys3.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen3\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") if iran_server: if "azumigen3" in active_int and "azumigen2" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m3 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m3 \033[92mOnline\033[0m" ) else: if "azumigen3" in active_int and "azumigen2" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m3 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 3 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 4): private_file = f"/etc/sys{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen2" in active_int: with open("/etc/sys2.sh", "r") as file: contents = file.read() ipv6_2 = "::2/64" in contents ipv6_1 = "::1/64" in contents if ipv6_2 and ipv6_1: index_2 = contents.index("::2/64") index_1 = contents.index("::1/64") iran_server = index_2 < index_1 else: iran_server = ipv6_2 if iran_server: print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen2\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") if iran_server: if "azumigen2" in active_int and "azumigen1" in active_int: print( " \033[92mIRAN \033[97mStatus : \033[96m2 \033[97mlocal Tunnels \033[92mOnline\033[0m" ) else: print( " \033[92mIRAN \033[97mStatus : \033[97mlocal Tunnel \033[96m2 \033[92mOnline\033[0m" ) else: if "azumigen2" in active_int and "azumigen1" in active_int: print( " \033[92mKharej \033[97mStatus : \033[96m2 \033[97mlocal Tunnels\033[96m \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[97mlocal Tunnel\033[96m 2 \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 3): private_file = f"/etc/sys{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: if iran_server: print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) elif "azumigen1" in active_int: with open("/etc/sys1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print(f" \033[97mIRAN SERVER \033[0m") else: print(f" \033[97mKHAREJ SERVER \033[0m") print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen1\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") with open("/etc/sys1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( " \033[92mIRAN \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) else: print( " \033[92mKharej \033[97mStatus : \033[96m1 \033[97mlocal Tunnel \033[92mOnline\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") for i in range(1, 2): private_file = f"/etc/sys{i}.sh" if os.path.exists(private_file): remote_ip = remote_extraction(private_file) if remote_ip: with open("/etc/sys1.sh", "r") as file: contents = file.read() match = re.search(r"::2/64", contents) if match: if match.start() < contents.index("::1/64"): print( f" \033[92mKHAREJ\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) else: print( f" \033[92mIRAN\033[93m IP for \033[96mlocal tunnel \033[92m{i}\033[93m: \033[97m{remote_ip}\033[0m" ) print("\033[93m─────────────────────────────────────────────────\033[0m") secret_key = ipsec_secret() if secret_key != "Not found": print(" \033[93mIPsec Secret Key:\033[96m", secret_key, "\033[0m") else: print(" \033[93mIPSEC is not available\033[0m") print("\033[93m─────────────────────────────────────────────────\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰─────────────────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": os.system("clear") status_mnu() break else: print("Invalid choice.") def single_status(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mSingle Status Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mYou are viewing the status of your current tunnels:\033[0m") interfaces = { "azumi": "azumi", "azumi6": "azumi6", "azumip": "azumip", "azumig": "azumig", "azumig6": "azumig6", "azumigen": "azumigen", "vxlan": "vxlan", } active_int = [] for interface, label in interfaces.items(): status = interface_check(interface) if status == "online": active_int.append(interface) if not active_int: print(" No Interfaces available.") elif "azumigen" in active_int and "azumig6" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names:\033[96m azumig6, azumigen\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6 Geneve\033[0m") private_sh = "/etc/private.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif "azumi" in active_int and "azumig6" in active_int: gre6_method = check_gre6() if gre6_method == "gre6tap": print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names:\033[96m azumi, azumig6\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6tap\033[0m") private_sh = "/etc/private.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif gre6_method == "gre6": print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names:\033[96m azumi, azumig6\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE6\033[0m") private_sh = "/etc/private.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif "azumip" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface names:\033[96m azumi, azumip\033[0m" ) print(" \033[93mTunnel Method: \033[97mIP6IP6\033[0m") private_sh = "/etc/private.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif os.path.exists("/etc/6to4.sh") and "azumi6" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi6\033[0m" ) print(" \033[93mTunnel Method: \033[97m6to4 Sit\033[0m") private_sh = "/etc/6to4.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type} \033[93mRemote IP: \033[97m{remote_ip}\033[0m" ) elif os.path.exists("/etc/private.sh") and "azumi" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumi\033[0m" ) print(" \033[93mTunnel Method: \033[97mPrivate Sit\033[0m") private_sh = "/etc/private.sh" if os.path.exists(private_sh): server_type = checktype(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif "vxlan" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m vxlan\033[0m" ) print(" \033[93mTunnel Method: \033[97mVxlan\033[0m") elif "azumig" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumig\033[0m" ) print(" \033[93mTunnel Method: \033[97mGRE\033[0m") private_sh = "/etc/gre.sh" if os.path.exists(private_sh): server_type = checktype2(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) elif "azumigen" in active_int: print( " \033[93mStatus: \033[92mOnline\033[97m | \033[93mInterface name:\033[96m azumigen\033[0m" ) print(" \033[93mTunnel Method: \033[97mGeneve UDP\033[0m") private_sh = "/etc/sys.sh" if os.path.exists(private_sh): server_type = checktypegen(private_sh) remote_ip = remote_extraction(private_sh) if remote_ip: print( f" \033[92m{server_type}\033[93m Remote IP: \033[97m{remote_ip}\033[0m" ) secret_key = ipsec_secret() if secret_key != "Not found": print(" \033[93mIPsec Secret Key:\033[96m", secret_key, "\033[0m") print("0. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: choice = input("\033[38;5;205mEnter your choice Please: \033[0m") if choice == "0": os.system("clear") status_mnu() break else: print("Invalid choice.") def geneve_gerk_version1(): gree6_kharej1() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_gerk_version2(): gree6_kharej1() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::2", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::2\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen_ipgeri(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_geri_version1() break elif server_type == "2": geneve_geri_version2() break else: print("Invalid choice.") def geneve_geri_version1(): gree6_iran1() ufw("66.200.1.1") ufw("66.200.2.1") ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_geri_version2(): gree6_iran1() ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw("2002:831a::1") ufw("2002:831a::2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", "2002:831a::1", ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote 2002:831a::1\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ##azumi native def gen2_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve + Native Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKHAREJ \033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_na_k() break elif server_type == "2": gen_na_i() break elif server_type == "3": clear() genz_ip() break else: print("Invalid choice.") def gen_na_k(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_nk_version1() break elif server_type == "2": geneve_nk_version2() break else: print("Invalid choice.") def geneve_nk_version1(): remote_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[96mNative \033[93m| \033[92mTunnelbroker\033[93m]: \033[0m" ) ufw(remote_ip) ufw("66.200.1.1") ufw("80.200.1.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/30", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/30 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="80.200.1.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_nk_version2(): remote_ip = input( "\033[93mEnter \033[92mIRAN\033[93m IPV6 address [\033[96mNative \033[93m| \033[92mTunnelbroker\033[93m]: \033[0m" ) ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def gen_na_i(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_ni_version1() break elif server_type == "2": geneve_ni_version2() break else: print("Invalid choice.") def geneve_ni_version1(): remote_ip = input( "\033[93mEnter \033[92mKHAREJ\033[93m IPV6 address [\033[96mNative \033[93m| \033[92mTunnelbroker\033[93m]: \033[0m" ) ufw(remote_ip) ufw("66.200.1.1") ufw("80.200.1.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "80.200.1.2/30", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 80.200.1.2/30 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.200.1.2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_ni_version2(): remote_ip = input( "\033[93mEnter \033[92mKHAREJ\033[93m IPV6 address [\033[96mNative \033[93m| \033[92mTunnelbroker\033[93m]: \033[0m" ) ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") ##### saki no def gen_ip(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mMethod 1[PointIP] \033[0m") print("2. \033[93mMethod 2[Route]\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": gen_ipm1() break elif server_type == "2": gen_ipm2() break elif server_type == "3": clear() genz_ip() break else: print("Invalid choice.") def gen_ipm2(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mMethod 2\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejm2_gen_menu() break elif server_type == "2": iranm2_gen_menu() break elif server_type == "3": clear() gen_ip() break else: print("Invalid choice.") def gen_ipm1(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mMethod 1\033[93m Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mKharej\033[0m") print("2. \033[93mIRAN\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": kharejm1_gen_menu() break elif server_type == "2": iranm1_gen_menu() break elif server_type == "3": clear() gen_ip() break else: print("Invalid choice.") def genkhm1_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "66.200.2.1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def genkhm2_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "80.200.1.2"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def genirm1_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "66.200.1.1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def genirm2_ping(): print("\033[93m─────────────────────────────────────────────────────────\033[0m") try: print("\033[96mPlease Wait, Azumi is pinging...") subprocess.run( ["ping", "-c", "2", "66.200.1.1"], check=True, stdout=subprocess.DEVNULL ) except subprocess.CalledProcessError as e: print(Fore.LIGHTRED_EX + "Pinging failed:", e, Style.RESET_ALL) def ping_kh_service(): service_content = """[Unit] Description=keepalive After=network.target [Service] ExecStart=/bin/bash /etc/ping_sys.sh Restart=always [Install] WantedBy=multi-user.target """ service_file_path = "/etc/systemd/system/ping_gen.service" with open(service_file_path, "w") as service_file: service_file.write(service_content) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "ping_gen.service"]) sleep(1) subprocess.run(["systemctl", "restart", "ping_gen.service"]) def gen_job(): file_path = "/etc/sys.sh" try: subprocess.run( f"(crontab -l | grep -v '{file_path}') | crontab -", shell=True, capture_output=True, text=True, ) subprocess.run( f"(crontab -l ; echo '@reboot /bin/bash {file_path}') | crontab -", shell=True, capture_output=True, text=True, ) display_checkmark("\033[92mCronjob added successfully!\033[0m") except subprocess.CalledProcessError as e: print("\033[91mFailed to add cronjob:\033[0m", e) def ufw(ip_address): subprocess.run(["sudo", "ufw", "allow", "from", ip_address]) def delufw(ip_address): subprocess.run(["sudo", "ufw", "delete", "allow", "from", ip_address]) def ipv4_address(): result = subprocess.run( ["curl", "-s", "https://ipinfo.io/ip"], capture_output=True, text=True ) return result.stdout.strip() def gen_ipvers(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_ipk_version1() break elif server_type == "2": geneve_ipk_version2() break else: print("Invalid choice.") def geneve_ipk_version1(): remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.1.1") ufw("66.200.2.1") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.2.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.2.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_ipk_version2(): remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejm1_gen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server \033[92mMethod 1\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") gen_ipvers() ## model 2 def gen_ipvers2(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_ipk1_version1() break elif server_type == "2": geneve_ipk1_version2() break else: print("Invalid choice.") def geneve_ipk1_version1(): remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.1.1") ufw("80.200.1.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.1.1/30", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.1.1/30 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.1.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="80.200.1.2" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def geneve_ipk1_version2(): remote_ip = input("\033[93mEnter \033[92mIRAN\033[93m IPV4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genkhm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (Kharej):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mIRAN IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mKharej Server Configuration Completed!\033[0m") def kharejm2_gen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mKharej server\033[92m Method 2\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring Kharej server...\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gen_ipvers2() def gen_ipver(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_ip_version1() break elif server_type == "2": geneve_ip_version2() break else: print("Invalid choice.") def geneve_ip_version1(): remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.1.1") ufw("66.200.2.1") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "66.200.2.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "route", "add", "66.200.1.1/32", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 66.200.2.1/32 dev azumigen\n") f.write("sudo ip route add 66.200.1.1/32 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 66.200.2.1\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_ip_version2(): remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranm1_gen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIran server\033[92m Method 1\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring for Iran server...\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") print("\033[93m─────────────────────────────────────────────────────────\033[0m") gen_ipver() def gen1_ipver(): print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose Geneve IP Version:\033[0m") print("1. \033[92mIPV4\033[0m") print("2. \033[93mIPV6\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": geneve_ipi_version1() break elif server_type == "2": geneve_ipi_version2() break else: print("Invalid choice.") def geneve_ipi_version1(): remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ufw(remote_ip) ufw("66.200.1.1") ufw("80.200.1.2") subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", "80.200.1.2/30", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write("sudo ip addr add 80.200.1.2/30 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") genirm1_ping() time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " 80.200.1.2\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") script_content = """#!/bin/bash ip_address="66.200.1.1" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{print $2}" | awk -F " " "{print $1}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def geneve_ipi_version2(): remote_ip = input("\033[93mEnter \033[92mKharej\033[93m IPV4 address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ufw(remote_ip) subprocess.run( [ "sudo", "ip", "link", "add", "name", "azumigen", "type", "geneve", "id", "1000", "remote", remote_ip, ], stdout=subprocess.DEVNULL, ) subprocess.run( ["sudo", "ip", "link", "set", "azumigen", "up"], stdout=subprocess.DEVNULL ) subprocess.run( ["sudo", "ip", "addr", "add", prefix + "/16", "dev", "azumigen"], stdout=subprocess.DEVNULL, ) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_notification("\033[93mAdding commands...\033[0m") print("\033[93m─────────────────────────────────────────────────────────\033[0m") with open("/etc/sys.sh", "w") as f: f.write( f"sudo ip link add name azumigen type geneve id 1000 remote {remote_ip}\n" ) f.write("sudo ip link set azumigen up\n") f.write(f"sudo ip addr add {prefix}/16 dev azumigen\n") set_mtu = input( "\033[93mDo you want to set the \033[92mMTU\033[96m [Geneve]\033[93m? (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired\033[92m MTU value\033[93m: \033[0m" ) mtu_command = f"ip link set dev azumigen mtu {mtu_value}\n" with open("/etc/sys.sh", "a") as f: f.write(mtu_command) subprocess.run(mtu_command, shell=True, check=True) print("\033[93m─────────────────────────────────────────────────────────\033[0m") display_checkmark("\033[92mConfiguration is done!\033[0m") gen_job() time.sleep(1) display_checkmark("\033[92mkeepalive service Configured!\033[0m") time.sleep(1) print("\033[93m─────────────────────────────────────────────────────────\033[0m") print("\033[93mCreated IP Addresses (IRAN):\033[0m") print("\033[92m" + "+---------------------------+" + "\033[0m") print("\033[92m" + " {}\033[0m".format(prefix)) print("\033[92m" + "+---------------------------+" + "\033[0m") remote_ipv4 = input( "\033[93mEnter \033[92mKharej IPv4\033[93m address [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) ufw(remote_prefix) script_content = """#!/bin/bash ip_address="{remote_prefix}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """.format( remote_prefix=remote_prefix ) with open("/etc/ping_sys.sh", "w") as script_file: script_file.write(script_content) os.chmod("/etc/ping_sys.sh", 0o755) ping_kh_service() print("\033[92mIRAN Server Configuration Completed!\033[0m") def iranm2_gen_menu(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mIran server\033[92m Method 2\033[0m") print('\033[92m "-"\033[93m═══════════════════════════\033[0m') display_notification("\033[93mConfiguring for Iran server...\033[0m") if os.path.isfile("/etc/sys.sh"): os.remove("/etc/sys.sh") print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") gen1_ipver() def i6to41_any_iran(): clear_screen() print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print( "\033[92m( ) \033[93m6to4 \033[92mIRAN\033[93m Menu\033[92m[Anycast]\033[0m" ) print('\033[92m "-"\033[93m════════════════════════════\033[0m') if ( subprocess.run(["test", "-f", "/etc/6to4.sh"], capture_output=True).returncode == 0 ): subprocess.run(["rm", "/etc/6to4.sh"]) display_notification("\033[93mConfiguring...\033[0m") local_ipv4 = server_ipv4() if local_ipv4 is None: return sleep(1) print("\033[93m╭─────────────────────────────────────────────────────────╮\033[0m") local_ip = input("\033[93mEnter \033[92mIran IPv4\033[93m address: \033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) ipv6_address = f'ipv4="{local_ipv4}"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`' ipv6_process = subprocess.run( ipv6_address, shell=True, capture_output=True, text=True ) if ipv6_process.returncode != 0: print("Error generating IPv6 address.") return ipv6 = ipv6_process.stdout.strip() print( "\033[93m│\033[0m \033[92mGenerated IPv6 address:\033[0m", ipv6, "\033[93m│\033[0m", ) with open("/etc/6to4.sh", "w") as f: f.write("#!/bin/bash\n") f.write("/sbin/modprobe sit\n") f.write( "/sbin/ip tunnel add azumi6 mode sit remote any local {} ttl 255\n".format( local_ip ) ) set_mtu = input( "\033[93mDo you want to set \033[92m MTU?\033[93m (\033[92myes\033[93m/\033[91mno\033[93m): \033[0m" ) if set_mtu.lower() == "yes" or set_mtu.lower() == "y": mtu_value = input( "\033[93mEnter the desired \033[92mMTU value\033[93m: \033[0m" ) f.write("/sbin/ip -6 link set dev azumi6 mtu {}\n".format(mtu_value)) else: f.write("/sbin/ip -6 link set dev azumi6 mtu 1480\n") f.write("/sbin/ip link set dev azumi6 up\n") f.write("/sbin/ip -6 addr add {}/16 dev azumi6\n".format(prefix)) f.write( "/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev azumi6 metric 1\n" ) answer = input( "\033[93mDo you want to change the \033[92mdefault route\033[93m? (\033[92my\033[93m/\033[91mn\033[93m)\033[0m " ) if answer.lower() in ["yes", "y"]: interface = ipv6_int() if interface is None: print("Error: No network interface with IPv6 address.") else: print("Interface:", interface) f.write( "ip -6 route replace default via fe80::1 dev {} src {}\n".format( interface, prefix ) ) else: print("Skipping changing the default route.") print("\033[93m─────────────────────────────────────────────────────────\033[0m") num_ips = int( input("\033[93mHow many \033[92madditional IPs\033[93m do you need? \033[0m") ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") start_index = 3 with open("/etc/6to4.sh", "a") as f: for i in range(start_index, start_index + num_ips): ip_addr = "2002:{:02x}{:02x}:{:02x}{:02x}::{:02x}/16".format( *map(int, ipv4.split(".")), i ) f.write("ip -6 addr add {} dev azumi6\n".format(ip_addr)) display_notification("\033[93mAdding cronjob!\033[0m") config_file_path = "/etc/6to4.sh" subprocess.run( f"(crontab -l | grep -v -F '{config_file_path}') | crontab -", shell=True, check=True, ) cronjob_command = ( f"(crontab -l 2>/dev/null; echo '@reboot sh {config_file_path}') | crontab -" ) subprocess.run(cronjob_command, shell=True, check=True) display_notification("\033[93mStarting 6to4...\033[0m") subprocess.run(["/bin/bash", "/etc/6to4.sh"]) num_servers = int( input( "\033[93mEnter the \033[92mnumber\033[93m of \033[96mServers\033[93m[Ping Service]? \033[0m" ) ) print("\033[93m╰─────────────────────────────────────────────────────────╯\033[0m") for i in range(num_servers): remote_ipv4 = input( f"\033[93mEnter \033[96mIPv4 address\033[93m of server \033[92m{i+1} [Ping Service]: \033[0m" ) remote_prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format( *map(int, remote_ipv4.split(".")) ) sleep(1) print("\033[92m(\033[96mPlease wait,Azumi is pinging...\033[0m") ping_result = subprocess.run( ["ping6", "-c", "2", remote_prefix], capture_output=True, text=True ).stdout.strip() print(ping_result) script_content = """#!/bin/bash ip_address="{}" max_pings=5 interval=2 while true do for ((i = 1; i <= max_pings; i++)) do ping_result=$(ping -c 1 $ip_address | grep "time=" | awk -F "time=" "{{print $2}}" | awk -F " " "{{print $1}}" | cut -d "." -f1) if [ -n "$ping_result" ]; then echo "Ping successful! Response time: $ping_result ms" else echo "Ping failed!" fi done echo "Waiting for $interval seconds..." sleep $interval done """ script_filename = f"/etc/ping_v6{i+1}.sh" with open(script_filename, "w") as f: f.write(script_content) subprocess.run(["chmod", "+x", script_filename]) service_filename = f"/etc/systemd/system/ping_v6{i+1}.service" with open(service_filename, "w") as f: f.write("[Unit]\n") f.write(f"Description=Ping Service {i+1}\n") f.write("After=network.target\n") f.write("\n") f.write("[Service]\n") f.write(f"ExecStart=/bin/bash {script_filename}\n") f.write("Restart=always\n") f.write("\n") f.write("[Install]\n") f.write("WantedBy=multi-user.target\n") subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", f"ping_v6{i+1}.service"]) subprocess.run(["systemctl", "start", f"ping_v6{i+1}.service"]) sleep(1) subprocess.run(["systemctl", "restart", f"ping_v6{i+1}.service"]) print( f"\033[92mPing service for server {i+1} has been added successfully!\033[0m" ) display_checkmark("\033[92m6to4 Service has been added successfully!\033[0m") def remove_6to4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92m6TO4\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/6to4.sh", shell=True) == 0: subprocess.run("rm /etc/6to4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot sh /etc/6to4.sh" | crontab -', shell=True ) subprocess.run("sudo rm /etc/ping_v6.sh", shell=True) time.sleep(1) subprocess.run("systemctl disable ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v6.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_6to41(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92m6TO4\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/6to4.sh", shell=True) == 0: subprocess.run("rm /etc/6to4.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot sh /etc/6to4.sh" | crontab -', shell=True ) subprocess.run("sudo rm /etc/ping_v6.sh", shell=True) time.sleep(1) subprocess.run("systemctl disable ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_v6.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v6.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v61.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v62.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v63.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v64.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl disable ping_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumi6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumi6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre.sh", shell=True) == 0: subprocess.run("rm /etc/gre.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot sh /etc/gre.sh" | crontab -', shell=True ) subprocess.run("sudo rm /etc/ping_ip.sh", shell=True) time.sleep(1) subprocess.run("systemctl disable ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre6(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if ( subprocess.call( "test -f /etc/gre6.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/gre6.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) if ( subprocess.call( "test -f /etc/private.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/private.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre6.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping_v6.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "sudo rm /etc/ping_ip.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "systemctl disable ping_ip.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping_ip.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping_ip.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "ip link set dev azumi down > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "ip tunnel del azumi > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "ip link set dev azumig6 down > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "ip tunnel del azumig6 > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre621(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre6.sh", shell=True) == 0: subprocess.run("rm /etc/gre6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_ip.sh", shell=True) subprocess.run("systemctl disable ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig6 down > /dev/null", shell=True) subprocess.run("ip tunnel del azumig6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_gre6tap21(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving \033[92mGRE6\033[93m Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/gre6.sh", shell=True) == 0: subprocess.run("rm /etc/gre6.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/gre6.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/ping_ip.sh", shell=True) subprocess.run("systemctl disable ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run("systemctl stop ping_ip.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_ip.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev azumig6 down > /dev/null", shell=True) subprocess.run("ip link delete azumig6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_privatesec(): remove_private() ipsecs_uninstall_private() def remove_private(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if ( subprocess.call( "test -f /etc/private.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/private.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/private.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping_v6.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "systemctl disable ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping_v6.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) time.sleep(1) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "ip link set dev azumi down > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "ip tunnel del azumi > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def prefix_ip_gen(): gen_path = "/etc/ping_sys.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as ping_gen_sh: for line in ping_gen_sh: if "ip_address" in line: ip_address = line.split("=")[-1].strip().strip('"') return ip_address return None def remote_ip_gen(): gen_path = "/etc/sys.sh" if not os.path.isfile(gen_path): return None with open(gen_path, "r") as gen_sh: for line in gen_sh: if "remote" in line: remote_ip = line.split()[-1].strip('"') return remote_ip return None def genz_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True, ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) delufw(prefix) remote_ip = remote_ip_gen() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) remote2_ip = prefix_ip_gen() if remote2_ip is None: print("Unable to retrieve prefix") else: delufw(remote2_ip) delufw("66.200.1.1") delufw("80.200.1.2") delufw("66.200.2.1") delufw("2001:db8::1") delufw("2001:db8::2") try: if ( subprocess.call( "test -f /etc/sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) == 0 ): subprocess.run( "rm /etc/sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab -', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo rm /etc/ping_sys.sh", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl stop ping_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "systemctl daemon-reload", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) subprocess.run( "sudo ip link delete azumigen > /dev/null", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def remove_test(): os.system("clear") print("\033[92m ^ ^\033[0m") print("\033[92m(\033[91mO,O\033[92m)\033[0m") print("\033[92m( ) \033[93mGeneve \033[92mIPsec\033[93m Uninstall Menu\033[0m") print('\033[92m "-"\033[93m══════════════════════════\033[0m') print("\033[93m╭───────────────────────────────────────╮\033[0m") print("\033[93mChoose what to do:\033[0m") print("1. \033[92mGeneve + IPsec\033[0m") print("2. \033[93mGeneve + GRE6 + IPsec\033[0m") print("3. \033[94mback to the previous menu\033[0m") print("\033[93m╰───────────────────────────────────────╯\033[0m") while True: server_type = input("\033[38;5;205mEnter your choice Please: \033[0m") if server_type == "1": remove_testz1() break elif server_type == "2": remove_testz2() break elif server_type == "3": clear() genx_ip() break else: print("Invalid choice.") def remove_testz1(): genz_uninstall() ipsecs_uninstall_gen() def remove_testz2(): genz_uninstall() gen6_uninstall() ipsecs_uninstall_gen() def gen4_uninstall(): remove_private() remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Geneve + \033[92mGRE6 + IP6tnl \033[93m+ \033[96mTunnel\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) delufw(prefix) remote_ip = remote_ip_gen() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) remote2_ip = prefix_ip_gen() if remote2_ip is None: print("Unable to retrieve prefix") else: delufw(remote2_ip) delufw("66.200.1.1") delufw("66.200.2.1") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2002:831b::2") delufw("2002:831b::1") delufw("2001:db8::1") delufw("2001:db8::2") try: if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_sys.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_gen.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumigen > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def gen2_uninstall(): remove_gre621() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Geneve + \033[92mGRE6 \033[93m+ \033[96mNATIVE Tunnel\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) delufw(prefix) remote_ip = remote_ip_gen() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) prefix = prefix_ip_gen() if prefix is None: print("Unable to retrieve prefix") else: delufw(prefix) delufw("66.200.1.1") delufw("66.200.2.1") delufw("2002:831a::1") delufw("2002:831a::2") try: if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_sys.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_gen.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumigen > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def gen6_uninstall(): remove_private() remove_gre6() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Geneve + \033[92mGRE6 \033[93m+ \033[96mIPV4\033[93m Tunnel\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") delufw("66.200.1.1") delufw("66.200.2.1") delufw("2002:831a::1") delufw("2002:831a::2") delufw("2002:831b::1") delufw("2002:831b::2") delufw("2001:db8::1") delufw("2001:db8::2") ipv4 = subprocess.run( ["curl", "-s", "https://api.ipify.org"], capture_output=True, text=True ).stdout.strip() prefix = "2002:{:02x}{:02x}:{:02x}{:02x}::1".format(*map(int, ipv4.split("."))) delufw(prefix) remote_ip = remote_ip_gen() if remote_ip is None: print("Unable to retrieve remote IP") else: delufw(remote_ip) prefix = prefix_ip_gen() if prefix is None: print("Unable to retrieve prefix") else: delufw(prefix) try: if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_sys.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_gen.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumigen > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) except Exception as e: print("Error:", str(e)) def gen3_uninstall(): remove_gre6() print("\033[93m───────────────────────────────────────\033[0m") display_notification( "\033[93mRemoving Geneve + \033[92mGRE6 \033[93m+ \033[96mNative\033[93m Tunnel\033[0m" ) print("\033[93m───────────────────────────────────────\033[0m") delufw("66.200.1.1") delufw("66.200.2.1") delufw("2002:831a::1") delufw("2002:831a::2") try: if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_sys.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_gen.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumigen > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def gen_icmp(): os.system("clear > /dev/null 2>&1") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Geneve + ICMP Tunnel...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") remove_icmp() subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/icmp.sh" | crontab - > /dev/null 2>&1', shell=True, ) remote2_ip = prefix_ip_gen() if remote2_ip is None: print("Unable to retrieve prefix") return delufw(remote2_ip) delufw("66.200.1.1") delufw("66.200.2.1") delufw("70.0.0.1") delufw("70.0.0.2") try: if subprocess.call("test -f /etc/sys.sh", shell=True) == 0: subprocess.run("rm /etc/sys.sh > /dev/null 2>&1", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/sys.sh" | crontab - > /dev/null 2>&1', shell=True, ) subprocess.run("sudo rm /etc/ping_sys.sh > /dev/null 2>&1", shell=True) subprocess.run( "systemctl disable ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop ping_gen.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/ping_gen.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl daemon-reload > /dev/null 2>&1", shell=True) subprocess.run("sudo ip link delete azumigen > /dev/null 2>&1", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private1s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates21.sh", shell=True) == 0: subprocess.run("rm /etc/privates21.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates21.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates22.sh", shell=True) == 0: subprocess.run("rm /etc/privates22.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates22.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates23.sh", shell=True) == 0: subprocess.run("rm /etc/privates23.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates23.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates24.sh", shell=True) == 0: subprocess.run("rm /etc/privates24.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates24.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates25.sh", shell=True) == 0: subprocess.run("rm /etc/privates25.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates25.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates26.sh", shell=True) == 0: subprocess.run("rm /etc/privates26.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates26.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates27.sh", shell=True) == 0: subprocess.run("rm /etc/privates27.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates27.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates28.sh", shell=True) == 0: subprocess.run("rm /etc/privates28.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates28.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates29.sh", shell=True) == 0: subprocess.run("rm /etc/privates29.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates29.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s2(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates210.sh", shell=True) == 0: subprocess.run("rm /etc/privates210.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates210.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings2_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings2_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # unistanll pre privateip 5 iran 10kharej server 3 def remove_private1s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates31.sh", shell=True) == 0: subprocess.run("rm /etc/privates31.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates31.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates32.sh", shell=True) == 0: subprocess.run("rm /etc/privates32.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates32.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates33.sh", shell=True) == 0: subprocess.run("rm /etc/privates33.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates33.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates34.sh", shell=True) == 0: subprocess.run("rm /etc/privates34.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates34.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates35.sh", shell=True) == 0: subprocess.run("rm /etc/privates35.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates35.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates36.sh", shell=True) == 0: subprocess.run("rm /etc/privates36.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates36.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates37.sh", shell=True) == 0: subprocess.run("rm /etc/privates37.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates37.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates38.sh", shell=True) == 0: subprocess.run("rm /etc/privates38.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates38.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates39.sh", shell=True) == 0: subprocess.run("rm /etc/privates39.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates39.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s3(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates310.sh", shell=True) == 0: subprocess.run("rm /etc/privates310.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates310.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings3_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings3_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # uninstall privateip 5 iran 10 kharej server 4 def remove_private1s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates41.sh", shell=True) == 0: subprocess.run("rm /etc/privates41.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates41.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates42.sh", shell=True) == 0: subprocess.run("rm /etc/privates42.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates42.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates43.sh", shell=True) == 0: subprocess.run("rm /etc/privates43.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates43.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates44.sh", shell=True) == 0: subprocess.run("rm /etc/privates44.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates44.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates45.sh", shell=True) == 0: subprocess.run("rm /etc/privates45.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates45.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates46.sh", shell=True) == 0: subprocess.run("rm /etc/privates46.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates46.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates47.sh", shell=True) == 0: subprocess.run("rm /etc/privates47.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates47.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates48.sh", shell=True) == 0: subprocess.run("rm /etc/privates48.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates48.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates49.sh", shell=True) == 0: subprocess.run("rm /etc/privates49.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates49.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s4(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates410.sh", shell=True) == 0: subprocess.run("rm /etc/privates410.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates410.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings4_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings4_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # uninstall 5 iran 10 kharej server 5 def remove_private1s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates51.sh", shell=True) == 0: subprocess.run("rm /etc/privates51.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates51.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates52.sh", shell=True) == 0: subprocess.run("rm /etc/privates52.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates52.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates53.sh", shell=True) == 0: subprocess.run("rm /etc/privates53.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates53.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates54.sh", shell=True) == 0: subprocess.run("rm /etc/privates54.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates54.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates55.sh", shell=True) == 0: subprocess.run("rm /etc/privates55.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates55.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates56.sh", shell=True) == 0: subprocess.run("rm /etc/privates56.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates56.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates57.sh", shell=True) == 0: subprocess.run("rm /etc/privates57.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates57.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates58.sh", shell=True) == 0: subprocess.run("rm /etc/privates58.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates58.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates59.sh", shell=True) == 0: subprocess.run("rm /etc/privates59.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates59.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s5(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates510.sh", shell=True) == 0: subprocess.run("rm /etc/privates510.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates510.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings5_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings5_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # iran side def remove_private1s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates21.sh", shell=True) == 0: subprocess.run("rm /etc/privates21.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates21.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates22.sh", shell=True) == 0: subprocess.run("rm /etc/privates22.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates22.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates23.sh", shell=True) == 0: subprocess.run("rm /etc/privates23.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates23.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates24.sh", shell=True) == 0: subprocess.run("rm /etc/privates24.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates24.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates25.sh", shell=True) == 0: subprocess.run("rm /etc/privates25.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates25.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates26.sh", shell=True) == 0: subprocess.run("rm /etc/privates26.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates26.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates27.sh", shell=True) == 0: subprocess.run("rm /etc/privates27.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates27.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates28.sh", shell=True) == 0: subprocess.run("rm /etc/privates28.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates28.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates29.sh", shell=True) == 0: subprocess.run("rm /etc/privates29.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates29.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings2_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings2_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s2i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates210.sh", shell=True) == 0: subprocess.run("rm /etc/privates210.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates210.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings2_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings2_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings2_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings2_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran2config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran2config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # unistanll pre privateip 5 iran 10kharej server 3 def remove_private1s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates31.sh", shell=True) == 0: subprocess.run("rm /etc/privates31.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates31.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates32.sh", shell=True) == 0: subprocess.run("rm /etc/privates32.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates32.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates33.sh", shell=True) == 0: subprocess.run("rm /etc/privates33.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates33.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates34.sh", shell=True) == 0: subprocess.run("rm /etc/privates34.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates34.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates35.sh", shell=True) == 0: subprocess.run("rm /etc/privates35.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates35.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates36.sh", shell=True) == 0: subprocess.run("rm /etc/privates36.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates36.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates37.sh", shell=True) == 0: subprocess.run("rm /etc/privates37.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates37.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates38.sh", shell=True) == 0: subprocess.run("rm /etc/privates38.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates38.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates39.sh", shell=True) == 0: subprocess.run("rm /etc/privates39.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates39.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings3_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings3_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s3i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates310.sh", shell=True) == 0: subprocess.run("rm /etc/privates310.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates310.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings3_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings3_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings3_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings3_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran3config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran3config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # uninstall privateip 5 iran 10 kharej server 4 def remove_private1s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates41.sh", shell=True) == 0: subprocess.run("rm /etc/privates41.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates41.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates42.sh", shell=True) == 0: subprocess.run("rm /etc/privates42.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates42.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates43.sh", shell=True) == 0: subprocess.run("rm /etc/privates43.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates43.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates44.sh", shell=True) == 0: subprocess.run("rm /etc/privates44.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates44.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates45.sh", shell=True) == 0: subprocess.run("rm /etc/privates45.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates45.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates46.sh", shell=True) == 0: subprocess.run("rm /etc/privates46.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates46.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates47.sh", shell=True) == 0: subprocess.run("rm /etc/privates47.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates47.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates48.sh", shell=True) == 0: subprocess.run("rm /etc/privates48.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates48.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates49.sh", shell=True) == 0: subprocess.run("rm /etc/privates49.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates49.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings4_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings4_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s4i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates410.sh", shell=True) == 0: subprocess.run("rm /etc/privates410.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates410.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings4_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings4_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings4_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings4_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran4config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran4config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # uninstall 5 iran 10 kharej server 5 def remove_private1s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates51.sh", shell=True) == 0: subprocess.run("rm /etc/privates51.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates51.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v61.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v61.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v61.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v61.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config1 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config1 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private2s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates52.sh", shell=True) == 0: subprocess.run("rm /etc/privates52.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates52.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v62.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v62.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v62.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v62.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config2 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config2 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private3s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates53.sh", shell=True) == 0: subprocess.run("rm /etc/privates53.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates53.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v63.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v63.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v63.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v63.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config3 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config3 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private4s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates54.sh", shell=True) == 0: subprocess.run("rm /etc/privates54.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates54.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v64.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v64.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v64.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v64.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config4 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config4 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def remove_private5s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates55.sh", shell=True) == 0: subprocess.run("rm /etc/privates55.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates55.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v65.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v65.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v65.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v65.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config5 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config5 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private6 def remove_private6s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates56.sh", shell=True) == 0: subprocess.run("rm /etc/privates56.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates56.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v66.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v66.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v66.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v66.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config6 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config6 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private7 def remove_private7s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates57.sh", shell=True) == 0: subprocess.run("rm /etc/privates57.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates57.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v67.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v67.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v67.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v67.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config7 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config7 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private8 def remove_private8s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates58.sh", shell=True) == 0: subprocess.run("rm /etc/privates58.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates58.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v68.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v68.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v68.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v68.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config8 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config8 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private9 def remove_private9s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates59.sh", shell=True) == 0: subprocess.run("rm /etc/privates59.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates59.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v69.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v69.service > /dev/null 2>&1", shell=True ) subprocess.run("systemctl stop pings5_v69.service > /dev/null 2>&1", shell=True) subprocess.run( "rm /etc/systemd/system/pings5_v69.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config9 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config9 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) # private10 def remove_private10s5i(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving private IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: if subprocess.call("test -f /etc/privates510.sh", shell=True) == 0: subprocess.run("rm /etc/privates510.sh", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/privates510.sh" | crontab -', shell=True, ) subprocess.run("sudo rm /etc/pings5_v610.sh", shell=True) time.sleep(1) subprocess.run( "systemctl disable pings5_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "systemctl stop pings5_v610.service > /dev/null 2>&1", shell=True ) subprocess.run( "rm /etc/systemd/system/pings5_v610.service > /dev/null 2>&1", shell=True ) time.sleep(1) subprocess.run("systemctl daemon-reload", shell=True) subprocess.run("ip link set dev iran5config10 down > /dev/null", shell=True) subprocess.run("ip tunnel del iran5config10 > /dev/null", shell=True) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 1 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mUninstall completed!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) def extra_uninstall(): os.system("clear") print("\033[93m───────────────────────────────────────\033[0m") display_notification("\033[93mRemoving Extra IP addresses...\033[0m") print("\033[93m───────────────────────────────────────\033[0m") try: interface = ( subprocess.check_output( "ip route | awk '/default/ {print $5; exit}'", shell=True ) .decode() .strip() ) addresses = ( subprocess.check_output( f"ip addr show dev {interface} | awk '/inet6 .* global/ {{print $2}}'", shell=True, ) .decode() .splitlines() ) for address in addresses: subprocess.run(f"ip addr del {address} dev {interface}", shell=True) display_notification("\033[93mRemoving cronjob...\033[0m") subprocess.run( 'crontab -l | grep -v "@reboot /bin/bash /etc/ipv6.sh" | crontab -', shell=True, ) sleep(1) subprocess.run("sudo rm /etc/ipv6.sh", shell=True) display_notification( "\033[93mRemoving Extra ip, Working in the background..\033[0m" ) print("Progress: ", end="") frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] delay = 0.1 duration = 3 end_time = time.time() + duration while time.time() < end_time: for frame in frames: print("\r[%s] Loading... " % frame, end="") time.sleep(delay) print("\r[%s] " % frame, end="") time.sleep(delay) display_checkmark("\033[92mExtra IP addresses removed successfully!\033[0m") except subprocess.CalledProcessError as e: print("Error:", e.output.decode().strip()) main_menu()